Last active
November 27, 2021 08:45
-
-
Save panzi/89fcaeb7ccb4e022aa7ffe25abf98e18 to your computer and use it in GitHub Desktop.
Delete an element by clicking it. Save this script as the URL of a bookmark, click the bookmark, and then click the element you want to delete. (Click Raw to get to a page that only shows the script source for easier copy-paste.)
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 cursor=document.body.style.cursor;var overlay=document.createElement('div');var iframeCatch=document.createElement('div');var style='border:1px solid #3280FF;background-color:rgba(50,128,255,0.5);position:absolute;z-index:2147483647;display:block;box-sizing:border-box;left:0;top:0;width:0;height:0;margin:0;padding:0;';var ev='pointer-events:none;';var tr='transition:width 60ms,height 60ms,left 60ms,top 60ms;';var br='border-radius:0;';style +=ev+'-webkit-'+ev+'-moz-'+ev;style +=tr+'-webkit-'+tr+'-moz-'+tr;style +=br+'-webkit-'+br+'-moz-'+br;overlay.setAttribute('style',style);document.body.appendChild(overlay);style='border:none;position:absolute;z-index:2147483647;display:none;box-sizing:border-box;left:0;top:0;width:0;height:0;margin:0;padding:0;';style +=br+'-webkit-'+br+'-moz-'+br;iframeCatch.setAttribute('style',style);iframeCatch.addEventListener('mouseout',function(event){this.style.display='none';},false);document.body.appendChild(iframeCatch);document.body.style.cursor="crosshair";var hoverElement=null;window.addEventListener('mouseover',onhover,true);window.addEventListener('click',onclick,true);window.addEventListener('keyup',onkeyup,true);function onhover(event){event.preventDefault();event.stopPropagation();iframeCatch.style.display='none';var docEl=document.documentElement;var body=document.body;var docY=docEl.clientTop||body.clientTop||0;var docX=docEl.clientLeft||body.clientLeft||0;var scrollY=window.pageYOffset||docEl.scrollTop||body.scrollTop||0;var scrollX=window.pageXOffset||docEl.scrollLeft||body.scrollLeft||0;hoverElement=document.elementFromPoint(event.clientX,event.clientY);var rect=hoverElement.getBoundingClientRect();var top=Math.floor(scrollY + rect.top)+'px';var left=Math.floor(scrollX + rect.left)+'px';var width=Math.floor(rect.width)+'px';var height=Math.floor(rect.height)+'px';overlay.style.left=left;overlay.style.top=top;overlay.style.width=width;overlay.style.height=height;if(hoverElement.nodeName==='IFRAME'){iframeCatch.style.left=left;iframeCatch.style.top=top;iframeCatch.style.width=width;iframeCatch.style.height=height;iframeCatch.style.display='block';}}function onclick(event){if(hoverElement&&hoverElement.parentNode){event.preventDefault();event.stopPropagation();hoverElement.parentNode.removeChild(hoverElement);clear();}}function onkeyup(event){if(event.keyCode===27){event.preventDefault();event.stopPropagation();clear();}}function clear(){if(overlay.parentNode)overlay.parentNode.removeChild(overlay);if(iframeCatch.parentNode)iframeCatch.parentNode.removeChild(iframeCatch);document.body.style.cursor=cursor;window.removeEventListener('mouseover',onhover,true);window.removeEventListener('click',onclick,true);window.removeEventListener('keyup',onkeyup,true);hoverElement=null;}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment