Skip to content

Instantly share code, notes, and snippets.

@agibsonsw
Created February 5, 2012 16:35
Show Gist options
  • Select an option

  • Save agibsonsw/1746472 to your computer and use it in GitHub Desktop.

Select an option

Save agibsonsw/1746472 to your computer and use it in GitHub Desktop.
JS Bookmarklet to hide an element on click
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);})()
@RodolpheGohard

Copy link
Copy Markdown

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