我想制作一个按钮(特别没有样式),可以打开和关闭此脚本
var meta = document.createElement('meta');
meta.httpEquiv = "refresh";
meta.content = "30"; //Change the 30 to however many seconds you want to wait
document.getElementsByTagName('head')[0].appendChild(meta);
setTimeout(function(){
if(document.getElementById("next-btn")){
document.getElementById("next-btn").click()
}
var choice = Math.floor(Math.random()*100) < 100; //Change the 93 to change percentage
if(choice){
document.querySelectorAll("input[value=Pass]") [0].click();
}else{
document.querySelectorAll("input[value=Fail]") [0].click();
}
}, 1000);
答案 0 :(得分:0)
这样的事情可能会起作用,但不确定你用什么来触发你的事件 HTML
<input type="button" onclick=OnOffAction()>
javasctip
var isOn = true;
function OnOffAction()
{
if(isOn) isOn = false;
else isOn = true;
}
var meta = document.createElement('meta');
meta.httpEquiv = "refresh";
meta.content = "30";
document.getElementsByTagName('head')[[0].appendChild(meta);
if(isOn)
{
setTimeout(function(){
if(document.getElementById("next-btn")){
document.getElementById("next-btn").click()
}
var choice = Math.floor(Math.random()*100) < 100;
if(choice){
document.querySelectorAll("input[value=Pass]") [0].click();
}else{
document.querySelectorAll("input[value=Fail]"). [0].click();
}
}, 1000);
}