How can I run javascript like a batch file?
I want to run the script below at midnight every day.
However, if you do a command in window.location.href, all subsequent JavaScript commands are ignored.
I want to register and run the task scheduler in Windows environment, but is there any possible way?
async function init() {
window.location.href = 'url where I want to go';
await timer(3000);
}
init().then(e => {
window.alert = function() {};
const lists = document.querySelectorAll('.List > div.board-list > div.list > table > tbody > tr');
const timer = ms => new Promise(res => setTimeout(res, ms))
async function load() {
for (let list of lists) {
console.log(list);
list.querySelector('td.list-btn > a.btn.btn-primary').click();
await timer(3000);
}
}
});
Best Regards!
To control a website, it needs to be loaded by a webbrowser. (for example Puppeteer, like Diego pointed out) You can find examples here. To execute the code once a day you can either use cron to call your file or use a package like Node schedule. With the secound solution the file needs to run already