dasdasd
This commit is contained in:
parent
b6b3751ee0
commit
0b1b5da719
@ -66,17 +66,27 @@ class SiteAdapter {
|
|||||||
this.log('info', `✓ 已清除 ${cookies.length} 个 Cookie`);
|
this.log('info', `✓ 已清除 ${cookies.length} 个 Cookie`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清除 localStorage 和 sessionStorage
|
// 清除 localStorage 和 sessionStorage(仅在有效页面)
|
||||||
await this.page.evaluate(() => {
|
const currentUrl = this.page.url();
|
||||||
localStorage.clear();
|
if (currentUrl && currentUrl.startsWith('http')) {
|
||||||
sessionStorage.clear();
|
await this.page.evaluate(() => {
|
||||||
});
|
try {
|
||||||
this.log('info', '✓ 已清除 localStorage 和 sessionStorage');
|
localStorage.clear();
|
||||||
|
sessionStorage.clear();
|
||||||
|
} catch (e) {
|
||||||
|
// 某些页面可能无法访问 storage
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.log('info', '✓ 已清除 localStorage 和 sessionStorage');
|
||||||
|
} else {
|
||||||
|
this.log('debug', '跳过 storage 清理(页面未加载)');
|
||||||
|
}
|
||||||
|
|
||||||
// 清除缓存(通过 CDP)
|
// 清除缓存(通过 CDP)
|
||||||
const client = await this.page.target().createCDPSession();
|
const client = await this.page.target().createCDPSession();
|
||||||
await client.send('Network.clearBrowserCookies');
|
await client.send('Network.clearBrowserCookies');
|
||||||
await client.send('Network.clearBrowserCache');
|
await client.send('Network.clearBrowserCache');
|
||||||
|
await client.detach();
|
||||||
this.log('info', '✓ 已清除浏览器缓存');
|
this.log('info', '✓ 已清除浏览器缓存');
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user