add logic to detect and handle login invalid - will exit auto start chat and show cookie assistant. add the logic to store cookie and local storage while auto start chat running.

This commit is contained in:
geekgeekrun
2024-03-03 23:28:36 +08:00
parent 6a7b402101
commit a25e7aedb9
7 changed files with 106 additions and 18 deletions
@@ -0,0 +1,18 @@
export const setDomainLocalStorage = async (browser, url, kv) => {
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', r => {
r.respond({
status: 200,
contentType: 'text/plain',
body: ':)',
});
});
await page.goto(url);
await page.evaluate(kv => {
Object.keys(kv).forEach(k => {
localStorage.setItem(k, kv[k]);
})
}, kv);
await page.close();
};