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.2.1
  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|pixiv.net).*/
  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 Include_Sites = ['163.com' , 'www.site.com' , 'www.site.com' , 'www.site.com'];
  69.  
  70. var Exclude_Sites = ['(www|drive|translate).google','youtube|bing|box|sync|dropbox|icloud|mega|mediafire.(?!com)'];
  71.  
  72. var Check_urlSite = window.location.href;
  73. var Match_Include = RegExp(Include_Sites.join('|')).exec(Check_urlSite);
  74. var Match_Exclude = RegExp(Exclude_Sites.join('|')).exec(Check_urlSite);
  75.  
  76. if (Match_Include) { ForceEnable (); }
  77. if (Match_Exclude) { } else {
  78. document.addEventListener("contextmenu", function(e){ e.stopPropagation ();}, true);}
  79.  
  80. GM_addStyle(`*{
  81. user-select:text!important;
  82. -moz-user-select:text!important;
  83. -webkit-user-select:text!important;
  84. -webkit-user-drag:text!important;
  85. -khtml-user-select:text!important;
  86. -khtml-user-drag:text!important;}}`);
  87.  
  88. function KeyPress (e) {
  89. if (e.altKey && e.ctrlKey) {
  90. alert("Absolute Right Click Mod Activate !!!");
  91. ForceEnable();
  92. }}
  93. document.addEventListener("keydown", KeyPress);
  94.  
  95. function ForceEnable () {
  96. document.addEventListener("copy", function(e){e.stopPropagation();},true);
  97. document.addEventListener("keyup", function(e){e.stopPropagation();},true);
  98. document.addEventListener("mouseup", function(e){ e.stopPropagation();},true);
  99. document.addEventListener("keydown", function(e){ e.stopPropagation();},true);
  100. document.addEventListener("mousedown", function(e){e.stopPropagation();},true);
  101. document.addEventListener("dragstart", function(e){ e.stopPropagation();},true);
  102. document.addEventListener("mousedown", function(e) { e.stopPropagation();},true);
  103. document.addEventListener("contextmenu", function(e){ e.stopPropagation();},true);
  104. document.addEventListener("selectstart", function(e){ e.stopPropagation();},true);}
  105.