Caixin Absolute Enable Right Click & Copy

Force Enable Right Click & Copy & Highlight

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