Created
February 5, 2012 16:35
-
-
Save agibsonsw/1746472 to your computer and use it in GitHub Desktop.
JS Bookmarklet to hide an element on click
This file contains hidden or 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);})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome ! this is so precious today with all that crap bloating every website out there ...
thanks for sharing!