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