Absolute Enable Right Click & Copy

Force Enable right click & Copy & Highlight

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

  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.5
  7. // @include http*://*
  8. // @icon https://cdn3.iconfinder.com/data/icons/communication-130/63/cursor-128.png
  9. // @copyright Absolute
  10. // @grant GM_addStyle
  11. // @Exclude /.*(JPG|PNG|GIF|JPEG|ico).*/
  12.  
  13. // ==/UserScript==
  14.  
  15. document.body.setAttribute('oncontextmenu', 'return true');
  16. document.body.setAttribute('onselectstart', 'return true');
  17. document.body.setAttribute('ondragstart', 'return true');
  18.  
  19. function clearEventListeners () {
  20. document.oncontextmenu = undefined;
  21. document.oncopy = undefined;
  22. document.oncut = undefined;
  23. document.onpaste = undefined;
  24. document.onselectstart = undefined;
  25. document.body.removeAttribute("oncopy");
  26. document.body.removeAttribute("ondrag");
  27. document.body.removeAttribute("oncontextmenu");
  28. document.body.removeAttribute("onselectstart");}
  29. window.addEventListener('load', clearEventListeners, false);
  30.  
  31. setInterval(function () {
  32. document.oncontextmenu=null;
  33. document.contextmenu=null;
  34. document.ondragstart=null;
  35. document.onkeydown=null;
  36. document.onmousedown=null;
  37. document.onmousemove=null;
  38. document.onmouseup=null;
  39. document.onselectstart=null;
  40. document.selectstart=null;
  41. document.body.oncopy=null;
  42. document.body.onselect=null;
  43. document.body.onbeforecopy=null;
  44. document.body.contextmenu=null;
  45. document.body.oncontextmenu=null;
  46. document.body.ondragstart=null;
  47. document.body.onkeydown=null;
  48. document.body.onmousedown=null;
  49. document.body.onmousemove=null;
  50. document.body.onmouseup=null;
  51. document.body.selectstart=null;
  52. document.body.onselectstart=null;
  53. document.oncopy=null;
  54. window.oncopy=null;
  55. window.contextmenu=null;
  56. window.oncontextmenu=null;
  57. window.ondragstart=null;
  58. window.onkeydown=null;
  59. window.onmousedown=null;
  60. window.onmousemove=null;
  61. window.onmouseup=null;
  62. window.selectstart=null;
  63. window.onselectstart=null;
  64. window.onbeforeprint=null;
  65. },2000);
  66.  
  67. var Elements = document.createElement('script');
  68. Elements.setAttribute('type', 'text/javascript');
  69. Elements.textContent = "$(function() {\n" + "$('body').off('copy contextmenu selectstart').unbind('contextmenu');\n" + "});";
  70. document.getElementsByTagName('body')[0].appendChild(Elements); [].forEach.call(document.querySelectorAll('[oncontextmenu]'),
  71. function(AllowCopy){AllowCopy.removeAttribute('oncontextmenu');}); [].forEach.call(document.querySelectorAll('[onselectstart="return false;"]'),
  72. function(AllowCopy){AllowCopy.removeAttribute('onselectstart');}); [].forEach.call(document.querySelectorAll('[onmousedown="return false;"]'),
  73. function(AllowCopy){AllowCopy.removeAttribute('onselectstart');}); [].forEach.call(document.querySelectorAll('[oncopy]'),
  74. function(AllowCopy){AllowCopy.removeAttribute('oncopy');});[].forEach.call(document.querySelectorAll('[unselectable]'),
  75. function(AllowCopy){AllowCopy.removeAttribute('unselectable');});
  76. if (document.onmousedown === 'rightclick') { document.onmousedown = ''; }
  77. if (document.oncontextmenu) { document.oncontextmenu = ''; }
  78. 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;}');
  79.  
  80.  
  81.  
  82.