I want to run something in the devtools console of a website with a node.js code, could anyone help me? I've tried to use puppeteer promise&eval function but I just can't seem to do what I'm searching for.
This is my code after I run chromium and open the website I want to go to.
console.log(await page.evaluate(
function login(token) {
setInterval(() => {
document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `"${token}"`
}, 50);
setTimeout(() => {
location.reload();
}, 2500);
}
));
page.waitFor( 2000 ).then(console.log('Next command'))
var account = "";
console.log(await page.evaluate(
account = `myaccount`
));
page.waitFor( 2000 ).then(console.log('Next command'))
console.log(await page.evaluate(
login(account)
varandloginin the page.evaluate(), I could only add the ''token'' manually via ''var token = "token"; then login(token); The second problem is that I want to include the function listed up with the timeouts and the interval, because when I did it I only managed to include it via document.body.appendChild.