Greasy Fork 支持简体中文。

Absolute Enable Right Click & Copy

Force Enable right click & Copy

目前為 2016-10-07 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Absolute Enable Right Click & Copy
  3. // @namespace Re-Enable right click Menu
  4. // @description Force Enable right click & Copy
  5. // @author Absolute
  6. // @version 1.1.3
  7. // @include http*://*
  8. ///@run-at document-start
  9. // @grant GM_addStyle
  10. // @icon https://cdn3.iconfinder.com/data/icons/communication-130/63/cursor-128.png
  11. // @Exclude http*://*.box.com/*
  12. // @Exclude /.*(JPG|PNG|GIF|JPEG|ico).*/
  13.  
  14. // ==/UserScript==
  15.  
  16. // Force Enable right click button
  17. document.body.addEventListener( "contextmenu", function(e) { e.stopPropagation(); } );
  18.  
  19. // Support to Enable Context Menu
  20. document.body.setAttribute('oncontextmenu', 'return true');
  21. document.body.setAttribute('onselectstart', 'return true');
  22. document.body.setAttribute('ondragstart', 'return true');
  23.  
  24. // Support to Enable Copy
  25. function clearEventListeners() {
  26. document.oncontextmenu = undefined;
  27. document.oncopy = undefined;
  28. document.oncut = undefined;
  29. document.onpaste = undefined;
  30. document.onselectstart = undefined;
  31. document.body.removeAttribute("oncopy");
  32. document.body.removeAttribute("ondrag");
  33. document.body.removeAttribute("oncontextmenu");
  34. document.body.removeAttribute("onselectstart");
  35. }
  36. window.addEventListener('load', clearEventListeners, false);
  37.  
  38. // Force Remove Copy Text Protection for All Sites
  39. setInterval(function() {
  40. document.oncontextmenu = null;
  41. document.contextmenu=null;
  42. document.ondragstart=null;
  43. document.onkeydown=null;
  44. document.onmousedown=null;
  45. document.onmousemove=null;
  46. document.onmouseup=null;
  47. document.onselectstart=null;
  48. document.selectstart=null;
  49. window.oncopy=null;
  50. document.oncopy=null;
  51. document.body.oncopy=null;
  52. document.body.onselect=null;
  53. document.body.onbeforecopy=null;
  54. document.body.contextmenu=null;
  55. document.body.oncontextmenu=null;
  56. document.body.ondragstart=null;
  57. document.body.onkeydown=null;
  58. document.body.onmousedown=null;
  59. document.body.onmousemove=null;
  60. document.body.onmouseup=null;
  61. document.body.selectstart=null;
  62. document.body.onselectstart=null;
  63. window.contextmenu=null;
  64. window.oncontextmenu=null;
  65. window.ondragstart=null;
  66. window.onkeydown=null;
  67. window.onmousedown=null;
  68. window.onmousemove=null;
  69. window.onmouseup=null;
  70. window.selectstart=null;
  71. window.onselectstart=null;
  72. window.onbeforeprint=null;
  73. },2000);
  74.  
  75. // Force Enable Copy & Highlight
  76. var scriptTag = document.createElement('script');
  77. scriptTag.setAttribute('type', 'text/javascript');
  78. scriptTag.textContent = "$(function() {\n" + "$('body').off('copy contextmenu selectstart').unbind('contextmenu');\n" + "});";
  79. document.getElementsByTagName('body')[0].appendChild(scriptTag);
  80. [].forEach.call(document.querySelectorAll('[oncontextmenu]'),
  81. function (targetNode) {
  82. targetNode.removeAttribute('oncontextmenu');});
  83. [].forEach.call(document.querySelectorAll('[onselectstart="return false;"]'),
  84. function (targetNode) {
  85. targetNode.removeAttribute('onselectstart');});
  86. [].forEach.call(document.querySelectorAll('[onmousedown="return false;"]'),
  87. function (targetNode) {
  88. targetNode.removeAttribute('onselectstart');});
  89. [].forEach.call(document.querySelectorAll('[oncopy]'),
  90. function (targetNode) {
  91. targetNode.removeAttribute('oncopy');});
  92. [].forEach.call(document.querySelectorAll('[unselectable]'),
  93. function (targetNode) {
  94. targetNode.removeAttribute('unselectable');});
  95. if (document.onmousedown === 'rightclick') { document.onmousedown = ''; }
  96. if (document.oncontextmenu) { document.oncontextmenu = ''; }
  97. GM_addStyle('* {user-select: text !important; -moz-user-select: text !important; -webkit-user-select: text !important; -webkit-user-drag: text !important; -khtml-user-select: text !important; -khtml-user-drag: text !important; }');
  98.  
  99.  
  100.