Javascript 使用GM禁用页面的焦点检查功能

Javascript 使用GM禁用页面的焦点检查功能,javascript,replace,greasemonkey,Javascript,Replace,Greasemonkey,我试图阻止一个页面在它认为失去焦点时自动停止。那么,如何使用GM禁用网页中的功能呢 我将尝试在页面上给出脚本,希望有人能帮助我更好地理解它,哈哈 <script> var nmn=0,isa=0,pr=1,wc=1,clkt='ptc',clki=303250,clkc=634089,capt=1367698325,stimg='http://something.com/img/',fxp=0,timer=30,tfrac=188,wmw=640,wmh=320,txbop='***

我试图阻止一个页面在它认为失去焦点时自动停止。那么,如何使用GM禁用网页中的功能呢

我将尝试在页面上给出脚本,希望有人能帮助我更好地理解它,哈哈

<script>
var nmn=0,isa=0,pr=1,wc=1,clkt='ptc',clki=303250,clkc=634089,capt=1367698325,stimg='http://something.com/img/',fxp=0,timer=30,tfrac=188,wmw=640,wmh=320,txbop='******************************\nThis website is attempting to break out of the frame.\nChoose to stay on this page otherwise you won\'t get paid.\n******************************',txtt='<table cellpadding=0 cellspacing=0><tr><td>',txet=txtt+'<img src="'+stimg+'error48.png" class=icon /><td>',txpb=txtt+'<img src="'+stimg+'clock48.png" class=icon /><td><div class=progressbar style=width:175px><div id=progress style=width:100%><\/div><\/div><div>',txtp='Please take time to visit<br />our sponsor\'s site below',txtp='<table cellpadding=0 cellspacing=0 id=pb><tr><td><img src="'+stimg+'clock48.png" class=icon /><td><div class=progressbar><div id=progress><\/div><\/div><div id=secs>30<\/div><div>'+txtp+'<\/div><\/table><table cellpadding=0 cellspacing=0 id=pe style=display:none><tr><td><img src="'+stimg+'error48.png" class=icon /><td id=ped><\/table>',txwm=txpb+'Please wait a moment<\/div><\/table>',txlw=txpb+'Please wait while<br>website is loading<\/div><\/table>',txcc='<div style=font-size:22px;line-height:20px>Click on the Cat<\/div><div class=msgx>Find below where the Cat is to continue<\/div>',txce=txet+'Your click has expired<div class=msgx>You\'ve waited too long to click<br><a href=javascript:; onclick=win.opener.reloadAds();win.close()>Close this window to try again<\/a><\/div><\/table>',txvc=txpb+'Validating your click<\/div><\/table>',txea=txet+'Unexpected error (#',txeb=')<div class=msgx><a href=javascript:; onclick=win.opener.reloadAds();win.close()>Close this window to try again<\/a><\/div><\/table>',txe1=txea+'304',txe2=txea+'305'+txeb,txe3=txea+'306'+txeb,txws='We\'re sorry but your browser<br />window is too small to view<br />this advert. Please resize.',txe4=txet+'You Are Not Signed In!<div class=msgx><a href=javascript:; onclick=win.opener.reloadAds();win.close()>Close this window to try again<\/a><\/div><\/table>',txfv=txpb+'Please wait while your<br />click is being validated<\/div><\/table>',txnf='<span style=cursor:pointer>You need to keep this advert<br />on focus to get credit<br /><a href=javascript:void(0); style=font-size:13px>Please click here to continue<\/a><\/span>';
var win=window,doc=document,sB=1,cx=0,xps=60,xpst=0,xpsi=0,xpsy=0,plc=0,ww=0,wh=0,wf=1,lwf=1,sw=0,sh=0,px=0,py=0,pg=0,pgId=0,lt=0,fc=0,st=0,lx=0,ld=0
</script>

<script>
if(typeof jQuery=='undefined')function il(){$('#msg').html(txet+'jQuery Javascript Library Missing/Blocked<div class=msgx><a href=javascript:; onclick=doc.location.reload(true)>Refresh this page<\/a> or <a href="/en/Helpdesk-Submit_a_Ticket?nsubject=jQuery+Not+Found+PTC+Site+%23303250" target=_blank>contact us<\/a> if this error persists<\/a><\/div><\/table>')}else{$(win).bind('beforeunload',function(){upp();if(sB)return txbop});$(win).focus(function(){wf=1}).blur(function(){wf=0});function rstc(){upp();if(sB)$.post('/ajax_clicks.php',{type:clkt,a:clki,b:clkc,c:2,d:0,w:ww,h:wh,f:lwf,sw:sw,sh:sh,px:px,py:py})}win.onunload=rstc;function il(){lx=1;win.clearTimeout(sTt);ia()}function ia(){if(ld||pr)return;ld=1;$('#msg').html(txtp);pg=(new Date()).getTime();lt=pg;pgId=setInterval(ib,tfrac)}
function upp(){px=(typeof win.screenLeft!='undefined'?win.screenLeft:win.screenX)-(typeof win.screen.left!='undefined'?win.screen.left:0),py=(typeof win.screenTop!='undefined'?win.screenTop:win.screenY);lwf=((typeof doc.hasFocus!='undefined'?doc.hasFocus():wf)?1:0);ww=$(win).width();wh=$(win).height();sw=win.screen.width,sh=win.screen.height}function ib(){if(fc)return;fc=1;var t=(new Date()).getTime();upp();if(!nmn){if(!isa&&(!lwf||px<=-32000)){pg=pg+(t-Math.min(t,lt));lt=t;if(st!=1){$('#pb').hide();$('#ped').html(txnf);$('#pe').show()}st=1}else if((ww<wmw||wh<wmh)){pg=pg+(t-Math.min(t,lt));lt=t;if(st!=2){$('#pb').hide();$('#ped').html(txws);$('#pe').show()}st=2}else{lt=t;if(st!=0){$('#pe').hide();$('#pb').show()}st=0}}t=(t-pg)/1000;
var p=(t/timer*100).toFixed(2);if(p>=100){win.clearInterval(pgId);p=100}$('.progressbar #progress').css('width',p+'%');$('#secs').text(timer-Math.round(t));if(p==100){sB=0;$('#msg').html(txfv);ic(0)}fc=0}function ip(){pr=0;if(lx)ia();else{$('#msg').html(txlw);sTt=win.setTimeout(ia,10000)}}function ic(v){upp();$.post('/ajax_clicks.php',{type:clkt,a:clki,b:clkc,c:1,d:cx,w:ww,h:wh,f:lwf,sw:sw,sh:sh,px:px,py:py,fxp:fxp},function(d){$('#msg').html(d);win.opener.reloadAds();win.focus();sB=0;$('#pnlnk').fadeIn();$('#clslnk').fadeIn()}).error(function(e){if(v==0)ic(1);else $('#msg').html(e.status==401?txe4:txe3)})}function rC(){win.clearTimeout(xpsy);win.clearInterval(xpsi);$('.xps').parent().hide()}function sC(){wc=1;$('#msg').html(txwm);rC();if(plc>=5){$('#msg').html(txtt+'<img src="'+stimg+'help48.png" class=icon /><td>'+txcc+'<\/table>');$('.capt').show().next().css('top','230px');xpsy=win.setTimeout(plx,30000)}else $('.capt').hide().next().css('top','100px')}
function hC(){rC();wc=0;$('.capt').hide().next().css('top','100px')}function ix(){xps=Math.round(60-(((new Date()).getTime()-xpst)/1000));if(xps<=0){hC();$('#msg').html(txce);rstc();sB=0}else $('.xps').html(xps)}function pl(){plc++;if(plc<5)return;if(wc)sC()}function plx(){$('.xps').html('60').parent().show();xpst=(new Date()).getTime();xpsi=win.setInterval(ix,1000)}function cC(b,v){$('#msg').html(txvc);hC();$.post('/ajax_clicks.php',{type:'captcha_click',a:clkc,b:b,c:capt},function(d){if(d.done)ip();else if(d.err){$('#msg').html(txet+d.err+'<\/table>');if(d.nc){capt=d.capt;plc=0;$('#cpics').html(d.nc)}else sB=0}},'json').error(function(e){if(e.status!=401&&v!=1)cC(b,1);else{if(e.status!=401)rstc();sB=0;$('#msg').html(e.status==401?txe4:txe1+'/'+e.status+txeb)}})}
function lC(v){plc=0;wc=0;sC();$.post('/ajax_clicks.php',{type:'captcha_reload',a:clkc},function(d){if(d.err)$('#msg').html(txet+d.err+'<\/table>');else{wc=1;capt=d.capt;$('#cpics').html(d.nc)}},'json').error(function(e){if(e.status!=401&&v!=1)lC(1);else{if(e.status!=401)rstc();sB=0;rC();$('#msg').html(e.status==401?txe4:txe2)}})}function fxd(){fxp=1}var sTt=0}
</script>
<script type="text/javascript">
var _qevents=_qevents||[];(function(){var elem=document.createElement('script');elem.src=(document.location.protocol=="https:"?"https://secure":"http://edge")+".quantserve.com/quant.js";elem.async=true;elem.type="text/javascript";var scpt=document.getElementsByTagName('script')[0];scpt.parentNode.insertBefore(elem,scpt);})();_qevents.push({qacct:"p-ebyIU3buIvZKo"});
</script>
我在错误控制台上没有错误,也没有发生任何事情


请,谢谢

通常,要通过手术禁用或更改页面的javascript,请使用checkForBadJavascripts,如中所示

但是,在本例中,页面使用的是document.hasFocus,因此仅劫持以下内容就足够了:

// ==UserScript==
// @name     _YOUR_SCRIPT_NAME
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// @run-at   document-start
// @grant    none
// ==/UserScript==

document.hasFocus = function () {return true;};

通常,要通过手术禁用或更改页面的javascript,请使用checkForBadJavascripts,如中所示

但是,在本例中,页面使用的是document.hasFocus,因此仅劫持以下内容就足够了:

// ==UserScript==
// @name     _YOUR_SCRIPT_NAME
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// @run-at   document-start
// @grant    none
// ==/UserScript==

document.hasFocus = function () {return true;};


这将不起作用,主要是因为您试图影响的JavaScript已经执行。我不知道您试图完成什么,但我建议您尝试恢复更改,而不是阻止更改。@JCOC611,防止损坏要比事后清理混乱好得多。幸运的是,在Firefox+Greasemonkey中,您可以使用阻止或更改攻击性的JS。@cripppplertd,有几种方法可以做到这一点,但看起来您可能试图欺骗网站的资金!请链接到该网站,并/或解释为什么这不会伤害他们。@BrockAdams我不认为这会骗走任何人的美元,哈哈,这是交易-我通常浏览2个流量交换和3个标签中的ptc,我使用tile view查看同一页面上的所有3个标签-但这个特定的网站计时器在不关注时停止,即使它被查看,我也会在这种情况下赔钱,哈哈。这不会起作用,主要是因为你试图影响的JavaScript已经被执行了。我不知道您试图完成什么,但我建议您尝试恢复更改,而不是阻止更改。@JCOC611,防止损坏要比事后清理混乱好得多。幸运的是,在Firefox+Greasemonkey中,您可以使用阻止或更改攻击性的JS。@cripppplertd,有几种方法可以做到这一点,但看起来您可能试图欺骗网站的资金!请链接到该网站,并/或解释为什么这不会伤害他们。@BrockAdams我不认为这会骗走任何人的美元,哈哈,这是交易-我通常浏览2个流量交换和3个标签中的ptc,我使用tile view查看同一页面上的所有3个标签-但这个特定的网站计时器在不关注时停止,即使它被观看,我也会在这种情况下赔钱,哈哈。如果焦点多次打开和关闭,这应该会起作用?是的。页面总是认为它有焦点。似乎不起作用-当我点击下一个标签时,它说窗口需要焦点。它在我的测试页面上运行良好。在控制台中,运行document.hasFocus.toString。您得到了什么?函数hasFocus{[本机代码]},如果focus多次打开和关闭,它应该可以工作?是的。页面总是认为它有焦点。似乎不起作用-当我点击下一个标签时,它说窗口需要焦点。它在我的测试页面上运行良好。在控制台中,运行document.hasFocus.toString。你得到了什么?函数hasFocus{[本机代码]}
// ==UserScript==
// @name     _YOUR_SCRIPT_NAME
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// @run-at   document-start
// @grant    none
// ==/UserScript==

document.hasFocus = function () {return true;};