Copying Lifted 解除复制限制

Allow your copying in anywhere.

  1. // ==UserScript==
  2. // @name Copying Lifted 解除复制限制
  3. // @name:en Copying Lifted
  4. // @name:zh-CN Copying Lifted 解除复制限制
  5. // @namespace https://palerock.cn
  6. // @version 0.3
  7. // @description:en Allow your copying in anywhere.
  8. // @description:zh-CN 让你在几乎所有网页里自由地复制粘贴,而不用担心被限制,或者被篡改复制内容
  9. // @require https://greasyfork.org/scripts/372672-everything-hook/code/Everything-Hook.js?version=659315
  10. // @include *
  11. // @author Cangshi
  12. // @match http://*/*
  13. // @run-at document-start
  14. // @grant none
  15. // @description Allow your copying in anywhere.
  16. // ==/UserScript==
  17.  
  18. function removeCopyEvent() {
  19. Array.prototype.concat.call(document.querySelectorAll('*'), document)
  20. .forEach(function (ele) {
  21. ele.oncopy = undefined;
  22. ele.oncontextmenu = undefined;
  23. });
  24. }
  25.  
  26. 'use strict';
  27. ~function (global) {
  28. function generate() {
  29. return function () {
  30.  
  31. global.addEventListener('contextmenu', function (e) {
  32. removeCopyEvent();
  33. });
  34.  
  35. global.addEventListener('keydown', function (e) {
  36. if (e.ctrlKey || e.keyCode === 224 || e.keyCode === 17 || e.keyCode === 91 || e.keyCode === 93) {
  37. removeCopyEvent();
  38. }
  39. });
  40.  
  41. this.hookBefore(EventTarget.prototype, 'addEventListener',
  42. function (m, args) {
  43. if (args[0] === 'copy' || args[0] === 'contextmenu') {
  44. args[0] = 'prevent ' + args[0] + ' handler';
  45. console.log('[AllowCopy Plugins]', args[0]);
  46. }
  47. }, false);
  48.  
  49. var style = 'body * :not(input):not(textarea){-webkit-user-select:auto!important;-moz-user-select:auto!important;-ms-user-select:auto!important;user-select:auto!important}';
  50.  
  51. var stylenode = document.createElement('style');
  52.  
  53. stylenode.setAttribute("type", "text/css");
  54. if (stylenode.styleSheet) {// IE
  55. stylenode.styleSheet.cssText = style;
  56. } else {// w3c
  57. var cssText = document.createTextNode(style);
  58. stylenode.appendChild(cssText);
  59. }
  60.  
  61. document.addEventListener('readystatechange', function () {
  62. if (document.readyState === "interactive" || document.readyState === "complete") {
  63. setTimeout(function () {
  64. document.head.appendChild(stylenode);
  65. console.log('[AllowCopy Plugins] css applied')
  66. }, 2000);
  67. }
  68. });
  69.  
  70. console.log('[AllowCopy Plugins]', 'works.');
  71. }
  72. }
  73.  
  74.  
  75. if (global.eHook) {
  76. global.eHook.plugins({
  77. name: 'allowCopy',
  78. /**
  79. * 插件装载
  80. * @param util
  81. */
  82. mount: generate()
  83. });
  84. }
  85. }(window);