Skip to content

Instantly share code, notes, and snippets.

@happiness801
Last active November 28, 2023 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save happiness801/47a881b53e605be3ec5d2b8e18433518 to your computer and use it in GitHub Desktop.
Save happiness801/47a881b53e605be3ec5d2b8e18433518 to your computer and use it in GitHub Desktop.
Element Destroyer
/**
* Planning to make this a shortcut to run, to add to a browser tab to
* make it really quick and easy to remove unnecessary elements (such as
* ads, modals, maybe paywalls)
*
* HERE IS THE BOOKMARKABLE VERSION:
ENABLE:
javascript:var KAG_mouseOver=function(o){o.style.border="1px solid red";o.style.overflow="auto"};var KAG_mouseOut=function(o){o.style.border=""};var KAG_click=function(e,o){e.stopPropagation();o.remove()};var elements=document.getElementsByTagName("*");for(var i=0;i<elements.length;i++){elements[i].addEventListener("mouseover",function(){KAG_mouseOver(this)});elements[i].addEventListener("mouseout",function(){KAG_mouseOut(this)});elements[i].addEventListener("click",function(event){KAG_click(event,this)})}
DISABLE:
javascript:KAG_mouseOver = () => {};KAG_mouseOut = () => {};KAG_click = () => {}
*/
var KAG_mouseOver = (o) => {
o.style.border = '1px solid red';
o.style.overflow = 'auto';
}
var KAG_mouseOut = (o) => {
o.style.border = '';
}
var KAG_click = (e, o) => {
e.stopPropagation();
o.remove();
}
// Get all the elements in the document
var elements = document.getElementsByTagName("*");
// Loop through each element
for (var i = 0; i < elements.length; i++) {
// Add an event listener for mouseover
elements[i].addEventListener("mouseover", function() { KAG_mouseOver(this) });
// Add an event listener for mouseout
elements[i].addEventListener("mouseout", function() { KAG_mouseOut(this) });
// Add an event listener for click
elements[i].addEventListener("click", function(event) { KAG_click(event, this) });
}
/*// To disable...
javascript: (function() {
KAG_mouseOver = () => {}
KAG_mouseOut = () => {}
KAG_click = () => {}
})();
//*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment