I've seen a lot of similar questions and I've tried everything I can think of to get this to work on my own.
First the relevant code (?from the target page?):
document.getElementById('btn_submit').innerHTML =
'<input type="hidden" value="17271" name="idofclick">
<input type="submit" value=" Click Me Now! " name="submit_com" class="padding2">';
Basically there is a timer on the page and the "click me now!" button appears after 3 secs, that's the part I want to click on.
This is my code. It's not working:
// ==UserScript==
// @name abc
// @namespace something
// @description abc Scripty
// @include *
// @version 1
// ==/UserScript==
(function ClicktheButton(obj) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
var canceled = !obj.dispatchEvent(evt);
/*
if(canceled) {
// A handler called preventDefault
alert("canceled");
} else {
// None of the handlers called preventDefault
alert("not canceled");
}
*/
}
var StupidButton = document.querySelector.innerHTML('input[type="submit"][value=" Click Me Now! "]');
ClicktheButton(StupidButton);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…