原始 PHP 代码:
var button='';
button+='<table border="0"id="table1"cellspacing="0"cellpadding="2"><tr><td>';
button+='<button type="submit" name="B5"style="height: 20; background-color: #0000FF; width:20" onclick="submitform(2);"></button></td>';
button+='<td>';button+='<button type="submit" name="B5"style="height: 20; background-color: #FFFF00; width:20" onclick="wrong();"></button></td>';
button+='</tr><tr><td>';button+='<button type="submit" name="B5"style="height: 20; background-color: #008000; width:20" onclick="wrong();"></button></td>';
button+='<td>';button+='<button type="submit" name="B5"style="height: 20; background-color: #FFFFFF; width:20" onclick="wrong();"></button></td>';
var button2='<button type="submit" name="B6" style="height: 20; background-color: #0000FF; width:20" disabled></button>';
在这种情况下,我想单击具有onclick
值submitform(2);
但没有值或 id 且名称相同的按钮。
我迷路了,这就是我尝试过的......
function clickb5 (jNode) {
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
jNode[0].dispatchEvent (clickEvent);
}
//-- Value match is case-sensitive
waitForKeyElements (
//"#btn_submit input[type='submit'][onclick*=submitform(1);]",
"input[type='submit'][onclick*=submitform(1);]",
clickb5
);
onclick*=submitform(1);
还附带 () 值 0,1,2,3,具体取决于页面。
但一次只做一件事...
有人可以帮忙吗?谢谢!
有效但不是最好的解决方案- 帮助获得随机时间?
setTimeout(Greasemonkey_main, 10000);
function Greasemonkey_main () {
unsafeWindow.submitform(0);
unsafeWindow.submitform(1);
unsafeWindow.submitform(2);
unsafeWindow.submitform(3);
}
谢谢大家!