rhardih / ekill

Chrome/Firefox extension to nuke annoying elements in a web page

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extension-Less Alternative

pronouncedJerry opened this issue · comments

save the following code as a bookmarklet
javascript:(function(){document.styleSheets[0].addRule(".highlighted_to_remove","background:red !important");var e=function(e){if(e.keyCode==27){i()}};document.addEventListener("keydown",e);var t=function(e){e.stopPropagation();this.classList.add("highlighted_to_remove");return false};var n=function(e){e.stopPropagation();this.classList.remove("highlighted_to_remove");return false};var r=function(e){this.parentNode.removeChild(this);i();e.preventDefault();e.stopPropagation();return false};var i=function(){var i=0;var s=document;while(s=document.body.getElementsByTagName("*").item(i++)){s.removeEventListener("mouseover",t);s.removeEventListener("mouseout",n);s.removeEventListener("click",r);s.classList.remove("highlighted_to_remove")}document.removeEventListener("keydown",e)};var s=0;var o=document;while(o=document.body.getElementsByTagName("*").item(s++)){o.addEventListener("mouseover",t);o.addEventListener("mouseout",n);o.addEventListener("click",r)}})()

Thanks Jerry - It is not practical, but it is fun. I placed the codes in console. It works quite well.

Nice, some guy actually asked for this on HN. Linked it there.

I believe that document.styleSheets[0].addRule is non-standard. Should be

document.styleSheets[0].insertRule(".highlighted_to_remove { background:red !important }")