After a lengthy search and multiple failed attempts with different files, I am in need of the following script:
If there is no interaction with a webpage for 1 minute, the script should automatically: - Click on a button. - Repeat the click every 30 seconds if there is still no interaction.
However, as soon as I start interacting with the webpage again, I want the script to stop running until I'm not interacting anymore.
I've managed to create this script:
function findButtonbyTextContent(text) {
var buttons = document.getElementsByTagName('button');
for (var i=0; i<buttons.length; i++) {
if (buttons[i].firstChild.nodeValue == text)
return buttons[i];
}
}
function refresh(tijd){
setInterval(findButtonbyTextContent("Refresh").click(), tijd);
}
document.onmousemove = (function() {
var onmousestop = function() {
refresh(30000);
}, thread;
return function() {
clearTimeout(thread);
thread = setTimeout(onmousestop, 60000);
};
})();