Last active
June 6, 2021 01:25
-
-
Save gosoccerboy5/8f14496565f1b005d85a6b3443c32014 to your computer and use it in GitHub Desktop.
Block elements on a webpage.
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: var evtHandler = function (e) { | |
e.preventDefault(); | |
e.stopPropagation(); | |
if (confirm("Do you want to delete this element?")) { | |
e.target.remove(); | |
} | |
document.body.removeEventListener("click", evtHandler); | |
}; | |
document.body.addEventListener("click", evtHandler); | |
// To use: run the code, click an element to delete it. | |
// Use at your own risk! If you do not trust the code, DO NOT USE IT! |
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:/*Thanks to uglifyjs.net */var evtHandler=function(e){e.preventDefault();e.stopPropagation();if(confirm("Do you want to delete this element?")){e.target.remove()}document.body.removeEventListener("click",evtHandler)};document.body.addEventListener("click",evtHandler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't work on <iframe> elements (which are used to host (Google) ads), so it kinda defeats the purpose 😅 😳
Note: you have to click it every time you want to block an element..