我刚刚开始为一个使用js运行的网站编写afk检查器旁路,但我需要代码帮助,因为我在js中非常新。我想做的是:我想写一个脚本,点击当一个窗口打开或模态我不知道它是什么有两个按钮和一个计时器-我将写下代码-一个按钮"事件"使我显示在线并隐藏消息框和其他按钮"Hayır"让我退出所以我想写一个脚本自动点击事件按钮计时器是30秒如果你不点击事件按钮30秒后自动点击"Hayır"并注销。
在这儿。
<
<div id="musercontrol" class="modal fade" role="dialog" style="display: none;" aria-hidden="true">
<div class="modal-dialog bounceInDown animated">
<div class="modal-content">
<div class="modal-header font-weight-bold text-uppercase d-flex py-3 align-items-center bg-danger text-white">
<div class="mr-1"><svg class="svg-inline--fa fa-id-badge fa-w-12 fa-fw fa-2x py-0" aria-hidden="true" focusable="false" data-prefix="far" data-icon="id-badge" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" data-fa-i2svg=""></svg><!-- <i class="far fa-id-badge fa-fw fa-2x py-0"></i> --> </div>
<div class="flex-fill">Orada mısınız ?</div>
</div>
<div class="modal-body d-block text-justify">
<div class="mb-2">you are afk now</div>
<div class="mb-2 text-center font-weight-bold">stay online?</div>
<div class="small font-italic text-muted mb-0">counter started.</div>
</div>
<div class="modal-footer d-flex py-1 align-self-stretch">
<a href="/safe-logoff/" class="btn btn-danger d-flex align-self-stretch text-uppercase">
<div class="align-self-center mr-2"><svg class="svg-inline--fa fa-times-circle fa-w-16 fa-fw" aria-hidden="true" focusable="false" data-prefix="far" data-icon="times-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""></svg><!-- <i class="far fa-times-circle fa-fw"></i> --> Hayır</div>
<div class="align-self-center small">(<span id="musercontroltimer" data-seconds-left="30" class="jst-timeout"></span>)</div>
</a>
<div class="flex-fill"></div>
<button type="button" class="btn btn-success text-uppercase" onclick="hidePortalTimeOut()"><svg class="svg-inline--fa fa-check-circle fa-w-16 fa-fw" aria-hidden="true" focusable="false" data-prefix="far" data-icon="check-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""></svg><!-- <i class="far fa-check-circle fa-fw"></i> --> Evet</button>
</div>
</div>
</div>
</div>
<script>
var PortalTimeOutStatus=0;
var PortalTimeOut=360000;
$(function(){setTimeout(function(){showPortalTimeOut();},PortalTimeOut)});
function showPortalTimeOut()
{
PortalTimeOutStatus=1;
$('#musercontroltimer').html('');
$('#musercontrol').modal({backdrop: "static"});
$('#musercontroltimer').startTimer({onComplete:function(){ if (PortalTimeOutStatus==1){location.href='/otomatik-safe-logoff/'}}});
}
function hidePortalTimeOut()
{
PortalTimeOutStatus=0
$('#musercontroltimer').html('');
$('#musercontroltimer').trigger('complete')
$('#musercontrol').modal('hide');
setTimeout(function(){showPortalTimeOut();},PortalTimeOut)
}
</script>
// ==UserScript==
// @name auto click for x
// @namespace http://tampermonkey.net/
// @version 3.0
// @description auto click afk check button
// @match bad website
// @author ace
// @grant none
// ==/UserScript==
window.onload=function ace(){
setInterval(ace,5);
}
function ace() {
document.querySelector(document).ready(function() {
document.querySelector("a:contains('Evet')").click();
});
};
我尝试了这个,并从chrome中获取错误,即:错误码:"SBOX_FATAL_MEMORY_EXCEEDED">
编辑1:我修改并删除了一些版权。
编辑2:
// ==UserScript==
// @name auto click for x
// @namespace http://tampermonkey.net/
// @version 3.0
// @description auto click afk check button
// @match bad site
// @author ace
// @grant none
// ==/UserScript==
window.onload=function ace(){
setInterval(ace,5);
}
function ace() {
document.querySelector(document).ready(function() {
var doc = document.querySelector(document).querySelector("a");
doc.each(function() {
if (document.querySelector(this).text() == "Evet") {
document.querySelector(this).click();
}
});
});
};
我试过这个,但这给了我什么网站。编辑2 .结束
尝试了这个,但也得到了超出的错误
// ==UserScript==
// @name auto click for x
// @namespace http://tampermonkey.net/
// @version 3.0
// @description auto click afk check button
// @match bad website
// @author ace
// @grant none
// ==/UserScript==
window.onload=function ace(){
setInterval(ace,5);
}
function ace() {
document.querySelector(document).ready(function() {
document.querySelector("button:contains('Evet')").click();
});
};