2013-05-05 97 views
1

我试图阻止页面停止自己,当它认为它失去了焦点。那么如何在使用GM的网页中禁用某个功能?使用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> 

现在我的一部分“认为”我想改变的是这个

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 varible将禁用此功能,如果页面心不是集中时停止计时。

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

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

我得到错误控制台上没有错误,没有任何反应。

请谢谢!

+0

这不会主要工作。我不知道你要完成什么,但我建议你尝试*恢复*变化而不是*阻止*它们。 – JCOC611 2013-05-05 04:43:12

+0

@ JCOC611,防止损坏比试图清理混乱之后好得多。幸运的是,在Firefox + Greasemonkey中,您可以使用[这种技术]阻止或更改令人讨厌的JS(http://stackoverflow.com/a/11201555/331508)。 – 2013-05-05 05:33:19

+0

@crippplertd,有几种方法可以做到这一点,但它看起来像你可能试图欺骗一个网站出钱!请链接到网站和/或解释为什么这不会伤害他们。 – 2013-05-05 05:34:58

回答

3

通常,要通过手术禁用或更改页面的JavaScript,请使用checkForBadJavascripts,如"How to alter this javascript with Greasemonkey?"所示。

然而,在这种情况下,页面使用document.hasFocus(),所以它应该是不够的,只是劫持的是:因为你试图影响的JavaScript已经执行

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

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

这应该工作,如果重点多次打开和关闭? – crippplertd 2013-05-05 06:22:29

+0

是的。该网页将始终认为它有重点。 – 2013-05-05 06:24:14

+0

似乎没有工作 - 当我点击下一个标签它说窗口需要专注 – crippplertd 2013-05-05 06:27:43