Skip to content

Instantly share code, notes, and snippets.

@soldair
Created April 23, 2010 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soldair/376793 to your computer and use it in GitHub Desktop.
Save soldair/376793 to your computer and use it in GitHub Desktop.
/* CPA LEAD AD NERF - stop cpa lead embedded ad widgets
copyright 2010 ryan day
http://ryanday.org
mit /gpl and all that
*/
/*
a co worker ran into a real ugly ad server that binds all sorts of unload callbacks and uses bad messaging in the onbefore unload confirmation box that would cause you to stay instead of leave. All to try and keep flashing ads in your face.
the source:
http://www.cpalead.com/
the best solution is to of course TURN OFF JS and enjoy the content but the challenge was too good to leave alone
GOAL:
about:blank s the first iframe which contains a survey or large ad
clear timeouts
gives you back scrollabillity of the page
takes all zindexed elements above 1000 and sticks them off left
the cpalead script would not take regular modification laying down. modifying or deleting the wroing attribute from the lightbox causes it to reload the page
*/
var fs = document.getElementsByTagName('iframe');
var f = fs[0];//check should be more robust
f.src = "about:blank";
(function (){
var ch = document.body.childNodes;
for(var i=0,j=ch.length;i<j;i++){
console.log(ch[i]);
if(ch[i].style){
if(ch[i].style.zIndex > 1000){
ch[i].style.top = '-10000px';
ch[i].style.left = '-10000px';
}
}
}
})();
function nerfTimers(window_obj){
var w = window;
if(window_obj) w = window_obj;
var current_index = w.setTimeout(function(){},0);
console.log(current_index);
while(current_index){
var n = current_index;
w.clearTimeout(n);
w.clearInterval(n);
current_index--;
if(current_index < nerfTimers.lastIndex) break;
}
console.log(current_index);
nerfTimers.lastindex = current_index;
}
var scrollfn = function(ev){
nerfTimers();
ev.stopPropagation();
return false;
};
window.addEventListener('scroll',scrollfn,true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment