初版:小白超人(从线上实例导出)
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
const edgePath = 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe';
|
||||
const nativeUa = 'Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 Chrome/153 Mobile Safari/537.36 xbniu-native/1.0';
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({ executablePath: edgePath, headless: true });
|
||||
for (const colorScheme of ['light', 'dark']) {
|
||||
const context = await browser.newContext({
|
||||
colorScheme,
|
||||
userAgent: nativeUa,
|
||||
viewport: { width: 530, height: 942 },
|
||||
deviceScaleFactor: 1,
|
||||
});
|
||||
const page = await context.newPage();
|
||||
page.on('dialog', dialog => dialog.dismiss());
|
||||
await page.goto(`http://127.0.0.1:98/?theme-check=${Date.now()}`, { waitUntil: 'domcontentloaded' });
|
||||
await page.waitForSelector('#native-tools');
|
||||
const result = await page.evaluate(() => {
|
||||
const button = document.querySelector('#auth-btn');
|
||||
const text = document.querySelector('#auth-btn-text');
|
||||
const avatar = document.querySelector('#auth-avatar');
|
||||
if (button) button.style.transition = 'none';
|
||||
button?.classList.add('logged-in');
|
||||
if (text) text.style.display = 'none';
|
||||
if (avatar) { avatar.style.display = 'flex'; avatar.textContent = '3'; }
|
||||
const inspect = selector => {
|
||||
const style = getComputedStyle(document.querySelector(selector));
|
||||
return {
|
||||
background: style.backgroundColor,
|
||||
color: style.color,
|
||||
border: style.borderColor,
|
||||
backdrop: style.backdropFilter || style.webkitBackdropFilter,
|
||||
};
|
||||
};
|
||||
return {
|
||||
htmlClass: document.documentElement.className,
|
||||
avatarClass: button?.className,
|
||||
avatarParent: button?.parentElement?.parentElement?.id,
|
||||
avatar: inspect('#auth-btn'),
|
||||
tools: inspect('#native-tools'),
|
||||
legend: inspect('.legend'),
|
||||
};
|
||||
});
|
||||
console.log(JSON.stringify({ colorScheme, ...result }));
|
||||
await context.close();
|
||||
}
|
||||
await browser.close();
|
||||
})();
|
||||
Reference in New Issue
Block a user