Created
February 5, 2012 16:35
JS Bookmarklet to hide an element on click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){var%20d=document,useMine=true,prevEl;function%20AddHandler(orig,mine) | |
{return%20function(e){if(useMine)mine(e);else%20if(orig)orig(e);};}function%20Myonmouseover(e) | |
{var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.outline='2px%20solid%20gray'; | |
prevEl=elem;}function%20Myonmouseout(e){var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.outline='';} | |
function%20Myonclick(e){var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.display='none';} | |
function%20Myonkeydown(e){var%20evt=e||window.event;if(evt.keyCode==27){prevEl.style.outline='';useMine=false;}} | |
d.onmouseover=AddHandler(d.onmouseover,Myonmouseover);d.onmouseout=AddHandler(d.onmouseout,Myonmouseout); | |
d.onclick=AddHandler(d.onclick,Myonclick);d.onkeydown=AddHandler(d.onkeydown,Myonkeydown);})() |
Awesome ! this is so precious today with all that crap bloating every website out there ...
thanks for sharing!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a bookmarklet I crafted so that I can click elements, images, on a web page to hide them.
Create a Bookmark and paste the code as the property for the bookmark. Add it as a button on your bookmarks toolbar. If you want to hide something, click the button. As you point around the page a grey box outlines what you will (try) to hide. You can continue clicking, then press Escape to finish.