Absolute Enable Right Click & Copy

Force Enable right click & Copy & Highlight

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

  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.9
  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 RemoveEvent () {
  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', RemoveEvent, 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 Exclude = ['app.box.com','www.dropbox.com','cp.sync.com','www.icloud.com','www.mega.nz','www.mediafire.com','translate.google','drive.google.com'];
  69.  
  70. var url = window.location.href;
  71. var Match = RegExp(Exclude.join('|')).exec(url);
  72. if (Match) { } else {
  73.  
  74. var Start = window.self;
  75. var Frame = Start.document;
  76. var iFrame = Frame.getElementsByTagName('body')[0];
  77. var ForceAdd = function(event) { event.stopImmediatePropagation(); };
  78.  
  79. iFrame.addEventListener('contextmenu',ForceAdd,true);
  80. iFrame.addEventListener('keydown',ForceAdd,true);
  81. iFrame.addEventListener('keyup',ForceAdd,true);
  82. iFrame.addEventListener('mouseup',ForceAdd,true);
  83. iFrame.addEventListener('mousedown',ForceAdd,true);
  84. iFrame.addEventListener('dragstart',ForceAdd,true);
  85. iFrame.addEventListener('selectstart',ForceAdd,true);
  86. iFrame.addEventListener('copy',ForceAdd,true);
  87. }
  88.  
  89. (function(css) {
  90. var head = Frame.getElementsByTagName("body")[0];
  91. if (head) {
  92. var style = Frame.createElement("style");
  93. style.textContent = css;
  94. style.type = "text/css";
  95. head.appendChild(style);
  96. }})('body, body * { -moz-user-focus:normal; -moz-user-select:text; -webkit-user-select:text; user-select:text; }');
  97.  
  98.