I'm trying to build a script that will click 3 buttons in succession but after clicking the first button, the script goes into infinite reloading.
The site I'm trying to click buttons on: JDoodle
You need to sign-in to see the buttons.
As you can see in the screenshots:
Button 1

Button 2

// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match *.jdoodle.com/*
// @grant none
// ==/UserScript==
'use strict';
$ = jQuery;
$(document).ready(function foo(){
var node = document.querySelectorAll('a');
node[8].click(); //clicking button 1
node = document.querySelector('[title="User\'s Saved Files"]');
node.click(); //clicking button 2
}
);
Tried approaches:
1.
unsafeWindow.r=0
if(unsafeWindow.r==0){
foo = function(){};
unsafeWindow.r=1;
}
Result : unsafeWindow.r not defined
2.
f = 1;
while(f){
if(document.querySelector('[title="User\'s Saved Files"]'))
f=0;
}
Result: Infinite reloading.
- Simply executing without approaches 1 & 2, no button is being clicked on by the script.
<a>element in the first place<a>element is a link to the same page, even if I handle that without click event, I will still have 2 other elements to click on one after another.node[8]seems pretty arbitrary, it could change at any moment.