Absolute Enable Right Click & Copy

Force Enable right click & Copy & Highlight

目前为 2016-10-25 提交的版本。查看 最新版本

  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.8
  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'];
  69. var url = window.location.href;
  70. var Match = RegExp(Exclude.join('|')).exec(url);
  71. if (Match) { }
  72. else {
  73. document.addEventListener("contextmenu", function(e) { e.stopPropagation (); }, true);
  74. }
  75.  
  76. var style = document.createElement('style');
  77. style.setAttribute('type','text/javascript');
  78. style.textContent = "$(function() {\n" + "$('body').off('copy contextmenu selectstart').unbind('contextmenu');\n" + "});";
  79. document.getElementsByTagName('body')[0].appendChild(style);[].forEach.call(document.querySelectorAll('[oncontextmenu]'),
  80. function(AllowCopy){AllowCopy.removeAttribute('oncontextmenu');});[].forEach.call(document.querySelectorAll('[onselectstart="return false;"]'),
  81. function(AllowCopy){AllowCopy.removeAttribute('onselectstart');});[].forEach.call(document.querySelectorAll('[onmousedown="return false;"]'),
  82. function(AllowCopy){AllowCopy.removeAttribute('onselectstart');});[].forEach.call(document.querySelectorAll('[oncopy]'),
  83. function(AllowCopy){AllowCopy.removeAttribute('oncopy');});[].forEach.call(document.querySelectorAll('[unselectable]'),
  84. function(AllowCopy){AllowCopy.removeAttribute('unselectable');});
  85. if (document.onmousedown === 'rightclick') { document.onmousedown = ''; }
  86. if (document.oncontextmenu) { document.oncontextmenu = ''; }
  87. 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;}');
  88.  
  89.