Absolute Enable Right Click & Copy

Force Enable Right Click & Copy & Highlight

目前為 2018-09-07 提交的版本,檢視 最新版本

  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 + `] Activate Absolute Right Click Mode To Force Remove Any Type Of Protection
  6. // @author Absolute
  7. // @version 1.8.9
  8. // @include *://*
  9. // @icon https://i.imgur.com/AC7SyUr.png
  10. // @compatible Chrome Google Chrome + Tampermonkey
  11. // @grant GM_registerMenuCommand
  12. // @license BSD
  13. // @copyright Absolute, 2016-Oct-06
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. var css = document.createElement('style');
  20. var head = document.head;
  21.  
  22. css.type = 'text/css';
  23.  
  24. css.innerText = `* {
  25. -webkit-user-select: text !important;
  26. -moz-user-select: text !important;
  27. -ms-user-select: text !important;
  28. user-select: text !important;
  29. }`;
  30.  
  31. function main() {
  32.  
  33. var doc = document;
  34. var body = document.body;
  35.  
  36. var docEvents = [
  37. doc.oncontextmenu = null,
  38. doc.onselectstart = null,
  39. doc.ondragstart = null,
  40. doc.onmousedown = null
  41. ];
  42.  
  43. var bodyEvents = [
  44. body.oncontextmenu = null,
  45. body.onselectstart = null,
  46. body.ondragstart = null,
  47. body.onmousedown = null,
  48. body.oncut = null,
  49. body.oncopy = null,
  50. body.onpaste = null
  51. ];
  52.  
  53. [].forEach.call(
  54. ['copy', 'cut', 'paste', 'select', 'selectstart'],
  55. function(event) {
  56. document.addEventListener(event, function(e) { e.stopPropagation(); }, true);
  57. }
  58. );
  59.  
  60. alwaysAbsoluteMode();
  61. enableCommandMenu();
  62. head.appendChild(css);
  63. document.addEventListener('keydown', keyPress);
  64. }
  65.  
  66. function keyPress(event) {
  67. if (event.ctrlKey && event.keyCode == 192) {
  68. return confirm('Activate Absolute Right Click Mode!') == true ? absoluteMode() : null;
  69. }
  70. }
  71.  
  72. function absoluteMode() {
  73. [].forEach.call(
  74. ['contextmenu', 'copy', 'cut', 'paste', 'mouseup', 'mousedown', 'keyup', 'keydown', 'drag', 'dragstart', 'select', 'selectstart'],
  75. function(event) {
  76. document.addEventListener(event, function(e) { e.stopPropagation(); }, true);
  77. }
  78. );
  79. }
  80.  
  81. function alwaysAbsoluteMode() {
  82. let sites = ['example.com','www.example.com'];
  83. const list = RegExp(sites.join('|')).exec(location.hostname);
  84. return list ? absoluteMode() : null;
  85. }
  86.  
  87. function enableCommandMenu() {
  88. var commandMenu = true;
  89. try {
  90. if (typeof(GM_registerMenuCommand) == undefined) {
  91. return;
  92. } else {
  93. if (commandMenu == true ) {
  94. GM_registerMenuCommand('Enable Absolute Right Click Mode', function() {
  95. return confirm('Activate Absolute Right Click Mode!') == true ? absoluteMode() : null;
  96. });
  97. }
  98. }
  99. }
  100. catch(err) {
  101. console.log(err);
  102. }
  103. }
  104.  
  105. var blackList = [
  106. 'youtube.com','.google.','.google.com','gf.qytechs.cn','twitter.com','instagram.com','facebook.com','translate.google.com','.amazon.','.ebay.','github.','stackoverflow.com',
  107. 'bing.com','live.com','.microsoft.com','dropbox.com','pcloud.com','box.com','sync.com','onedrive.com','mail.ru','deviantart.com','pastebin.com',
  108. 'dailymotion.com','twitch.tv','spotify.com','steam.com','steampowered.com','gitlab.com','.reddit.com'
  109. ]
  110.  
  111. var enabled = false;
  112. var url = window.location.hostname;
  113. var match = RegExp(blackList.join('|')).exec(url);
  114.  
  115. if (window && typeof window != undefined && head != undefined) {
  116.  
  117. if (!match && enabled != true) {
  118.  
  119. main();
  120. enabled = true
  121.  
  122. //console.log(location.hostname);
  123.  
  124. window.addEventListener('contextmenu', function contextmenu(event) {
  125. event.stopPropagation();
  126. event.stopImmediatePropagation();
  127. var handler = new eventHandler(event);
  128. window.removeEventListener(event.type, contextmenu, true);
  129. var eventsCallBack = new eventsCall(function() {});
  130. handler.fire();
  131. window.addEventListener(event.type, contextmenu, true);
  132. if (handler.isCanceled && (eventsCallBack.isCalled)) {
  133. event.preventDefault();
  134. }
  135. }, true);
  136. }
  137.  
  138. function eventsCall() {
  139. this.events = ['DOMAttrModified', 'DOMNodeInserted', 'DOMNodeRemoved', 'DOMCharacterDataModified', 'DOMSubtreeModified'];
  140. this.bind();
  141. }
  142.  
  143. eventsCall.prototype.bind = function() {
  144. this.events.forEach(function (event) {
  145. document.addEventListener(event, this, true);
  146. }.bind(this));
  147. };
  148.  
  149. eventsCall.prototype.handleEvent = function() {
  150. this.isCalled = true;
  151. };
  152.  
  153. eventsCall.prototype.unbind = function() {
  154. this.events.forEach(function (event) {}.bind(this));
  155. };
  156.  
  157. function eventHandler(event) {
  158. this.event = event;
  159. this.contextmenuEvent = this.createEvent(this.event.type);
  160. }
  161.  
  162. eventHandler.prototype.createEvent = function(type) {
  163. var target = this.event.target;
  164. var event = target.ownerDocument.createEvent('MouseEvents');
  165. event.initMouseEvent(
  166. type, this.event.bubbles, this.event.cancelable,
  167. target.ownerDocument.defaultView, this.event.detail,
  168. this.event.screenX, this.event.screenY, this.event.clientX, this.event.clientY,
  169. this.event.ctrlKey, this.event.altKey, this.event.shiftKey, this.event.metaKey,
  170. this.event.button, this.event.relatedTarget
  171. );
  172. return event;
  173. };
  174.  
  175. eventHandler.prototype.fire = function() {
  176. var target = this.event.target;
  177. var contextmenuHandler = function(event) {
  178. event.preventDefault();
  179. }.bind(this);
  180. target.dispatchEvent(this.contextmenuEvent);
  181. this.isCanceled = this.contextmenuEvent.defaultPrevented;
  182. };
  183.  
  184. }
  185.  
  186. })();
  187.  

QingJ © 2025

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