Absolute Enable Right Click & Copy

Force Enable Right Click & Copy & Highlight

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

  1. // ==UserScript==
  2. // @name Absolute Enable Right Click & Copy
  3. // @namespace Absolute Right Click
  4. // @description Force Enable Right Click & Copy & Highlight
  5. // @shortcutKeys [Ctrl + Alt] Activate Absolute Right Click Mod To Force Remove Any Type Of Protection
  6. // @author Absolute
  7. // @version 1.2.6
  8. // @include http*://*
  9. // @icon https://cdn3.iconfinder.com/data/icons/communication-130/63/cursor-128.png
  10. // @license BSD
  11. // @copyright Absolute, All Right Reserved (2016)
  12. // @grant GM_addStyle
  13. // @Exclude /.*(JPG|PNG|GIF|JPEG|ico|www.google.[^]|bing.com|facebook.com|pixiv.net).*/
  14.  
  15. // ==/UserScript==
  16.  
  17. var Sites_List = ['163.com','www.site.com','www.site.com','www.site.com'];
  18.  
  19. (function GetSelection () {
  20. var style = document.createElement('style');
  21. var iStyle = '*{user-select:text!important;-webkit-user-select:text!important;}';
  22. style.type = 'text/css';
  23. if (style.styleSheet) { style.styleSheet.cssText = iStyle; }
  24. else { style.appendChild(document.createTextNode(iStyle)); }
  25. window.getSelection = null;
  26. document.oncontextmenu = null;
  27. document.getElementsByTagName('head')[0].appendChild(style);
  28. })();
  29.  
  30. (function CheckEvents () {
  31. var events = ['oncut','oncopy','ondragstart','onselectstart','oncontextmenu'];
  32. for (var i = 0; i < events.length; i++)
  33. document.body.setAttribute(events[i],'null');
  34. })();
  35.  
  36. (function FixEvents () {
  37. var events = ['contextmenu'];
  38. for (var i = 0; i < events.length; i++) {
  39. document.addEventListener(events[i],function(e){e.stopPropagation();});
  40. document.addEventListener(events[i],function(e){e.stopImmediatePropagation();});
  41. }})();
  42.  
  43. (function RightClickButton () {
  44. function EventsCall (callback) {
  45. this.isCalled = false;
  46. this.isUnbound = false;
  47. this.callback = callback;
  48. this.events = ['DOMAttrModified','DOMNodeInserted','DOMNodeRemoved','DOMCharacterDataModified','DOMSubtreeModified'];
  49. this.bind();
  50. }
  51. EventsCall.prototype.bind = function () {
  52. this.events.forEach(function (event) {
  53. document.addEventListener(event, this, true);
  54. }.bind(this));
  55. };
  56. EventsCall.prototype.handleEvent = function () {
  57. this.isCalled = true;
  58. this.unbind();
  59. };
  60. EventsCall.prototype.unbind = function () {
  61. if (this.isUnbound) {
  62. return;
  63. }
  64. this.events.forEach(function (event) {
  65. document.removeEventListener(event, this, true);
  66. }.bind(this));
  67. this.isUnbound = true;
  68. };
  69. function Synchronization () {
  70. }
  71. Synchronization.prototype.restore = function () {
  72. this.isRestoration = true;
  73. };
  74. function EventHandler (event) {
  75. this.event = event;
  76. this.contextmenuEvent = this.createEvent(this.event.type);
  77. }
  78. EventHandler.prototype.createEvent = function (type) {
  79. var target = this.event.target;
  80. var event = target.ownerDocument.createEvent('MouseEvents');
  81. event.initMouseEvent(type, this.event.bubbles, this.event.cancelable,
  82. target.ownerDocument.defaultView, this.event.detail,
  83. this.event.screenX, this.event.screenY, this.event.clientX, this.event.clientY,
  84. this.event.ctrlKey, this.event.altKey, this.event.shiftKey, this.event.metaKey,
  85. this.event.button, this.event.relatedTarget);
  86. return event;
  87. };
  88. EventHandler.prototype.fire = function () {
  89. var target = this.event.target;
  90. var contextmenuHandler = function (event) {
  91. event.preventDefault();
  92. }.bind(this);
  93. window.addEventListener(this.event.type, contextmenuHandler, false);
  94. target.dispatchEvent(this.contextmenuEvent);
  95. window.removeEventListener(this.event.type, contextmenuHandler, false);
  96. this.isCanceled = this.contextmenuEvent.defaultPrevented;
  97. };
  98. window.addEventListener('contextmenu', handleEvent, true);
  99. function handleEvent (event) {
  100. event.stopPropagation();
  101. event.stopImmediatePropagation();
  102. var handler = new EventHandler(event);
  103. window.removeEventListener(event.type, handleEvent, true);
  104. var sync = new Synchronization();
  105. var EventsCallBback = new EventsCall(function () {
  106. sync.restore();
  107. });
  108. handler.fire();
  109. window.addEventListener(event.type, handleEvent, true);
  110. if (handler.isCanceled && (EventsCallBback.isCalled)) {
  111. event.preventDefault();
  112. }}})();
  113.  
  114. (function CheckIncludeSites () {
  115. var Check = window.location.href;
  116. var Match = RegExp(Sites_List.join('|')).exec(Check);
  117. if (Match) { Absolute_Mod(); }
  118. })();
  119.  
  120. function KeyPress (e) {
  121. if (e.altKey && e.ctrlKey) {
  122. alert("Absolute Right Click Mod Activate !!!");
  123. Absolute_Mod();}}
  124. document.addEventListener("keydown", KeyPress);
  125.  
  126. function Absolute_Mod () {
  127. var events = ['contextmenu','copy','mouseup','mousedown','keyup','keydown','dragstart','selectstart'];
  128. for (var i = 0; i < events.length; i++) {
  129. document.addEventListener(events[i],function(e){e.stopPropagation();},true);
  130. }}
  131.  
  132.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址