使用GM禁用页面的焦点检查功能 [英] Disabling a page's focus-checking function using GM

查看:56
本文介绍了使用GM禁用页面的焦点检查功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当它认为页面失去焦点时,我正试图阻止该页面停止运行.那么如何使用GM禁用网页中的功能?

I'm trying to stop a page from stopping itself when it thinks it's lost focus. So How do I disabling a function within webpage using GM?

我将通过在页面上提供脚本来尝试,希望有人可以帮助我更好地对其进行解密,大声笑.

I'll try by giving the script on the page, hopefully someone can help me decipher it better, LOL.

<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>

现在我想改变的部分就是这个

Now the part I 'think' I want to change is this

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>';

我的想法是,如果页面没有被关注,那么更改txnf变量将禁用此功能,该功能将停止计时器.

My thinking is that changing the txnf varible will disable this function that stops a timer if the page isnt focused upon.

这是我没有成功尝试过的代码.

Here's the code I tried with no sucess..

document.head.innerHTML= document.head.innerHTML.replace('txnf','');

我在错误控制台上没有收到任何错误,什么也没发生.

I get no error on error console and nothing happens.

请谢谢!

推荐答案

通常,要通过外科手术方式禁用或更改页面的javascript,请使用checkForBadJavascripts,如.

In general, to surgically disable or alter a page's javascript, use checkForBadJavascripts as shown in "How to alter this javascript with Greasemonkey?".

但是,在这种情况下,页面使用的是document.hasFocus(),因此只要劫持该页面就足够了:

However, in this case, the page is using document.hasFocus(), so it should be enough to just hijack that:

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

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

这篇关于使用GM禁用页面的焦点检查功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆