1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| var x = document.getElementsByClassName("goog-button-base-content"); var element=x[(x.length-1)]; counter = 0; var dispatchMouseEvent = function(target, var_args) { var e = document.createEvent("MouseEvents"); // If you need clientX, clientY, etc., you can call // initMouseEvent instead of initEvent e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1)); target.dispatchEvent(e); };
function c(){ if('Continue »'==element.innerHTML){ // Do something after the sleep! dispatchMouseEvent(element, 'mouseover', true, true); dispatchMouseEvent(element, 'mousedown', true, true); dispatchMouseEvent(element, 'click', true, true); dispatchMouseEvent(element, 'mouseup', true, true);
} }
function myLoop () { // create a loop function setTimeout(function () { // call a 3s setTimeout when the loop is called myLoop(); // .. again which will trigger another c(); // Main function counter++ console.log(counter); // .. setTimeout() }, 1000) }
|