Absolute Enable Right Click & Copy

Force Enable right click & Copy & Highlight

当前为 2016-10-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Absolute Enable Right Click & Copy
  3. // @namespace Absolute Right Click
  4. // @description Force Enable right click & Copy & Highlight
  5. // @author Absolute
  6. // @version 1.1.7
  7. // @include http*://*
  8. // @icon https://cdn3.iconfinder.com/data/icons/communication-130/63/cursor-128.png
  9. // @license BSD
  10. // @copyright Absolute
  11. // @grant GM_addStyle
  12. // @Exclude /.*(JPG|PNG|GIF|JPEG|ico).*/
  13.  
  14. // ==/UserScript==
  15.  
  16. document.body.setAttribute('oncontextmenu', 'return true');
  17. document.body.setAttribute('onselectstart', 'return true');
  18. document.body.setAttribute('ondragstart', 'return true');
  19.  
  20. function clearEventListeners () {
  21. document.oncontextmenu = undefined;
  22. document.oncopy = undefined;
  23. document.oncut = undefined;
  24. document.onpaste = undefined;
  25. document.onselectstart = undefined;
  26. document.body.removeAttribute("oncopy");
  27. document.body.removeAttribute("ondrag");
  28. document.body.removeAttribute("oncontextmenu");
  29. document.body.removeAttribute("onselectstart");}
  30. window.addEventListener('load', clearEventListeners, false);
  31.  
  32. setInterval(function () {
  33. document.oncontextmenu=null;
  34. document.contextmenu=null;
  35. document.ondragstart=null;
  36. document.onkeydown=null;
  37. document.onmousedown=null;
  38. document.onmousemove=null;
  39. document.onmouseup=null;
  40. document.onselectstart=null;
  41. document.selectstart=null;
  42. document.body.oncopy=null;
  43. document.body.onselect=null;
  44. document.body.onbeforecopy=null;
  45. document.body.contextmenu=null;
  46. document.body.oncontextmenu=null;
  47. document.body.ondragstart=null;
  48. document.body.onkeydown=null;
  49. document.body.onmousedown=null;
  50. document.body.onmousemove=null;
  51. document.body.onmouseup=null;
  52. document.body.selectstart=null;
  53. document.body.onselectstart=null;
  54. document.oncopy=null;
  55. window.oncopy=null;
  56. window.contextmenu=null;
  57. window.oncontextmenu=null;
  58. window.ondragstart=null;
  59. window.onkeydown=null;
  60. window.onmousedown=null;
  61. window.onmousemove=null;
  62. window.onmouseup=null;
  63. window.selectstart=null;
  64. window.onselectstart=null;
  65. window.onbeforeprint=null;
  66. },2000);
  67.  
  68. var style = document.createElement('style');
  69. style.setAttribute('type', 'text/javascript');
  70. style.textContent = "$(function() {\n" + "$('body').off('copy contextmenu selectstart').unbind('contextmenu');\n" + "});";
  71. document.getElementsByTagName('body')[0].appendChild(style);[].forEach.call(document.querySelectorAll('[oncontextmenu]'),
  72. function(AllowCopy){AllowCopy.removeAttribute('oncontextmenu');});[].forEach.call(document.querySelectorAll('[onselectstart="return false;"]'),
  73. function(AllowCopy){AllowCopy.removeAttribute('onselectstart');});[].forEach.call(document.querySelectorAll('[onmousedown="return false;"]'),
  74. function(AllowCopy){AllowCopy.removeAttribute('onselectstart');});[].forEach.call(document.querySelectorAll('[oncopy]'),
  75. function(AllowCopy){AllowCopy.removeAttribute('oncopy');});[].forEach.call(document.querySelectorAll('[unselectable]'),
  76. function(AllowCopy){AllowCopy.removeAttribute('unselectable');});
  77. if (document.onmousedown === 'rightclick') { document.onmousedown = ''; }
  78. if (document.oncontextmenu) { document.oncontextmenu = ''; }
  79. 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;}');
  80.  
  81. // Add Here Any Site to Activate "Absolute Right Click Enable Mod"
  82. var List = [ 'www.Site.com' ,'www.Site.com' , 'www.Site.com' ];
  83. Url = new RegExp(List.join('|'), "i");
  84. if (Url.test(document.body.textContent)) {
  85. document.addEventListener("contextmenu", function(e){ e.stopPropagation ();}, true);}
  86.  
  87.