Anti Right-Click Hijaak

Prevent websites from changing or preventing your right click menu

  1. // ==UserScript==
  2. // @name Anti Right-Click Hijaak
  3. // @version 0.3
  4. // @description Prevent websites from changing or preventing your right click menu
  5. // @grant GM_registerMenuCommand
  6. // @run-at document-start
  7. // @match *://*/*
  8. // @license MIT
  9. // @namespace https://greasyfork.org/users/1253611
  10. // ==/UserScript==
  11. GM_registerMenuCommand("Include Current Site", includeSite);
  12. GM_registerMenuCommand("Exclude Current Site", excludeSite);
  13. if (localStorage.getItem("included") === window.location.hostname) {
  14. // Add event listeners only if the conditions are met
  15. document.addEventListener("copy", (event) => { event.stopImmediatePropagation(); }, true);
  16. document.addEventListener("paste", (event) => { event.stopImmediatePropagation(); }, true);
  17. document.addEventListener("contextmenu", (event) => { event.stopImmediatePropagation(); }, true);
  18. }
  19.  
  20.  
  21. function includeSite() {
  22. localStorage.setItem("included", window.location.hostname); // Change "included" to something else if multiple userscripts use this code
  23. }
  24.  
  25. function excludeSite() {
  26. localStorage.removeItem("included", window.location.hostname);
  27. }