Allow Right-Click with Tampermonkey Menu Option

Allows right-clicking on websites that prevent it by clicking the menu button in the Tampermonkey extension.

目前为 2024-11-25 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Allow Right-Click with Tampermonkey Menu Option
  3. // @namespace https://github.com/Nick2bad4u/UserStyles
  4. // @version 1.6
  5. // @description Allows right-clicking on websites that prevent it by clicking the menu button in the Tampermonkey extension.
  6. // @author Nick2bad4u
  7. // @match *://*/*
  8. // @grant GM_registerMenuCommand
  9. // @icon https://i.gyazo.com/353b60294e0dc77af7119d58ab0aa1ad.png
  10. // @license UnLicense
  11. // @tag all
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16.  
  17. // Function to enable right-click
  18. function enableRightClick() {
  19. document.addEventListener(
  20. 'contextmenu',
  21. function (event) {
  22. event.stopPropagation();
  23. },
  24. true
  25. );
  26.  
  27. document.addEventListener(
  28. 'mousedown',
  29. function (event) {
  30. if (event.button === 2) {
  31. event.stopPropagation();
  32. }
  33. },
  34. true
  35. );
  36.  
  37. document.addEventListener(
  38. 'mouseup',
  39. function (event) {
  40. if (event.button === 2) {
  41. event.stopPropagation();
  42. }
  43. },
  44. true
  45. );
  46.  
  47. alert('Right-click has been enabled!');
  48. }
  49.  
  50. // Register the option in the Tampermonkey menu
  51. GM_registerMenuCommand('Enable Right-Click', enableRightClick);
  52. })();