Caixin Absolute Enable Right Click & Copy

Force Enable Right Click & Copy & Highlight

当前为 2021-02-22 提交的版本,查看 最新版本

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