Skip to content

Commit

Permalink
fix: localstorage无法访问
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Apr 4, 2024
1 parent 3eb58de commit f2c1e9f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ require("dotenv").config();
page.on("pageerror", (error) => {
console.error(`Page error: ${error.message}`);
});
page.on("error", (error) => {
page.on("error", async (error) => {
console.error(`Error: ${error.message}`);
// 检查是否是 localStorage 的访问权限错误
if (
error.message.includes(
"Failed to read the 'localStorage' property from 'Window'"
)
) {
console.log("Trying to refresh the page to resolve the issue...");
await page.reload(); // 刷新页面
// 重新尝试你的操作...
}
});
page.on("console", (msg) => console.log("PAGE LOG:", msg.text()));
// // 监听所有请求
Expand Down

0 comments on commit f2c1e9f

Please sign in to comment.