3 つのボタンを連続してクリックするスクリプトを作成しようとしていますが、最初のボタンをクリックした後、スクリプトは無限にリロードされます。
ボタンをクリックしようとしているサイト: JDoodle
ボタン
を表示するにはサインインする必要があります。スクリーンショットでわかるように:
ボタン 1
ボタン 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
}
);
試みたアプローチ:
1.
unsafeWindow.r=0
if(unsafeWindow.r==0){
foo = function(){};
unsafeWindow.r=1;
}
結果 :unsafeWindow.r not defined
2.
f = 1;
while(f){
if(document.querySelector('[title="User\'s Saved Files"]'))
f=0;
}
結果: 無限のリロード。
- アプローチ 1 と 2 を使用せずに実行するだけで、スクリプトによってボタンがクリックされることはありません。