Prevent Right-Click Context Menu Hijaak

Prevent websites from entirely disable web browser's Right-Click context menu by allowing use of SHIFT+RightClick, CTRL+RightClick, or CTRL+SHIFT+RightClick (configurable in the script code). This script is designed for Chrome and Chromium based web browsers. Firefox already has this feature built in via SHIFT+RightClick.

  1. // ==UserScript==
  2. // @name Prevent Right-Click Context Menu Hijaak
  3. // @namespace https://gf.qytechs.cn/en/users/85671-jcunews
  4. // @version 1.0.2
  5. // @license AGPLv3
  6. // @author jcunews
  7. // @description Prevent websites from entirely disable web browser's Right-Click context menu by allowing use of SHIFT+RightClick, CTRL+RightClick, or CTRL+SHIFT+RightClick (configurable in the script code). This script is designed for Chrome and Chromium based web browsers. Firefox already has this feature built in via SHIFT+RightClick.
  8. // @match *://*/*
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (() => {
  14. //=== CONFIGURATION BEGIN ===
  15.  
  16. //At least either SHIFT or CTRL should be set to true.
  17. let useShift = true;
  18. let useCtrl = false;
  19.  
  20. //=== CONFIGURATION END ===
  21.  
  22. let epd = Event.prototype.preventDefault;
  23. Event.prototype.preventDefault = function() {
  24. if (this.type === "contextmenu") {
  25. if (((useShift && this.shiftKey) && (useCtrl && this.ctrlKey)) || (useShift && this.shiftKey) || (useCtrl && this.ctrlKey)) return;
  26. }
  27. return epd.apply(this, arguments);
  28. };
  29. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址