Skip to content

Instantly share code, notes, and snippets.

@vercte
Last active May 17, 2022 18:38
Show Gist options
  • Save vercte/d66501e498903f6937e3faf1c2ce302d to your computer and use it in GitHub Desktop.
Save vercte/d66501e498903f6937e3faf1c2ce302d to your computer and use it in GitHub Desktop.
Removlet (bookmarklet)

Removlet

Easily remove elements from a page, with a easy interface! Click to remove an element, and alt+enter to stop removing until you click again.

Installation

Highlight the entirety of removlet.txt and drag it to the bookmarks bar. If you have suspicion of any bugs, look in the dev console and report any errors to me!

NOTE: Do not use this bookmark twice before disabling it; it will bug out that way.

// removlet explained
alert("Removlet is on. Press ALT + ENTER to disable.");
$e_ = null;
$c_ = null;
// remove element code
function $r_(e){
e.preventDefault();
e.target.remove()
}
// highlight element code
function $h_(e){
e.preventDefault();
// turn the last hightlighted element back
if($e_){
$e_.style.background=$c_;
}
// save the neccessary styles
$e_ = e.target;
$c_ = e.target.style.background;
// turn it red
e.target.style.background="red"
}
// attempt to fix double click bug (not working)
document.removeEventListener("click",$r_);
document.removeEventListener("mousemove", $h_);
// add listeners for removing the elements
document.addEventListener("click",$r_);
document.addEventListener("mousemove", $h_);
document.addEventListener("keydown", ({key, altKey}) => {
if(key=="Enter"&&altKey){
document.removeEventListener("click",$r_);
document.removeEventListener("mousemove", $h_);$e_.style.background=$c_;
}
});
// for use in javascript console
alert("Removlet is on. Press ALT + ENTER to disable.");$e_ = null;$c_ = null;function $r_(e){e.preventDefault();e.target.remove()};function $h_(e){e.preventDefault();if($e_){$e_.style.background=$c_;} $e_ = e.target; $c_ = e.target.style.background;e.target.style.background="red"}document.removeEventListener("click",$r_);document.removeEventListener("mousemove", $h_);document.addEventListener("click",$r_); document.addEventListener("mousemove", $h_);document.addEventListener("keydown", ({key, altKey}) => {if(key=="Enter"&&altKey){document.removeEventListener("click",$r_);document.removeEventListener("mousemove", $h_);$e_.style.background=$c_;}});
javascript:alert("Removlet is on. Press ALT + ENTER to disable.");$e_ = null;$c_ = null;function $r_(e){e.preventDefault();e.target.remove()};function $h_(e){e.preventDefault();if($e_){$e_.style.background=$c_;} $e_ = e.target; $c_ = e.target.style.background;e.target.style.background="red"}document.removeEventListener("click",$r_);document.removeEventListener("mousemove", $h_);document.addEventListener("click",$r_); document.addEventListener("mousemove", $h_);document.addEventListener("keydown", ({key, altKey}) => {if(key=="Enter"&&altKey){document.removeEventListener("click",$r_);document.removeEventListener("mousemove", $h_);$e_.style.background=$c_;}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment