Unlimit-Web

解除网页限制: 恢复文本的选中和复制, 过滤文本小尾巴, 恢复右键菜单. Remove webpage restrictions: restore the selection and copy of text, clear the text tail, and restore the right-click menu.

目前为 2023-11-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Unlimit-Web
  3. // @description 解除网页限制: 恢复文本的选中和复制, 过滤文本小尾巴, 恢复右键菜单. Remove webpage restrictions: restore the selection and copy of text, clear the text tail, and restore the right-click menu.
  4. // @version 6.0
  5. // @author xcanwin
  6. // @namespace https://github.com/xcanwin/Unlimit-Web/
  7. // @supportURL https://github.com/xcanwin/Unlimit-Web/
  8. // @icon data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" stroke-width="2" fill="none" stroke="currentColor"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path></svg>
  9. // @license GPL-2.0-only
  10. // @match *://blog.csdn.net/*
  11. // @match *://www.bilibili.com/*
  12. // @match *://360doc.com/*
  13. // @match *://guofeng.yuedu.163.com/*
  14. // @match *://kuwo.cn/*
  15. // @match *://chuangshi.qq.com/*
  16. // @match *://read.qidian.com/*
  17. // @match *://dafrok.github.io/*
  18. // @match *://shushan.zhangyue.net/*
  19. // @match *://aqistudy.cn/*
  20. // @match *://xuexila.com/*
  21. // @match *://51test.net/*
  22. // @match *://laokaoya.com/*
  23. // @match *://utaten.com/*
  24. // @match *://book.qq.com/*
  25. // @match *://doc.mbalib.com/*
  26. // @match *://oh100.com/*
  27. // @match *://51test.net/*
  28. // @match *://cspengbo.com/*
  29. // @match *://diyifanwen.com/*
  30. // @match *://ahsrst.cn/*
  31. // @match *://kt250.com/*
  32. // @match *://*/*
  33. // @grant GM_getValue
  34. // @grant GM_setValue
  35. // @grant GM_registerMenuCommand
  36. // @grant GM_unregisterMenuCommand
  37. // @run-at document-end
  38. // ==/UserScript==
  39.  
  40. (function() {
  41. 'use strict';
  42.  
  43. const $ = (Selector, el) => (el || document).querySelector(Selector);
  44. const $$ = (Selector, el) => (el || document).querySelectorAll(Selector);
  45.  
  46. const sv = (key, value = "") => {
  47. GM_setValue(key, value);
  48. };
  49.  
  50. const gv = (key, value = "") => {
  51. return GM_getValue(key, value);
  52. };
  53.  
  54. const unLimit = () => {
  55. $$("*").forEach(el => {
  56. [
  57. "user-select", "-webkit-user-select", "-moz-user-select", "-ms-user-select", "-khtml-user-select", "pointer-events",
  58. ].forEach(xcanwin => {
  59. const ec = el.childNodes;
  60. const j1 = ec && ec.length == 1 && ec[0] && ec[0].nodeType && ec[0].nodeType == 3;
  61. const style = document.defaultView.getComputedStyle(el, null)[xcanwin];
  62. const j2 = style && style != 'auto';
  63. if (j1 || j2){
  64. // 处理第一个子标签是text类型的标签,处理select值被修改过的标签
  65. el.style.setProperty(xcanwin, "text", "important");
  66. }
  67. });
  68.  
  69. [
  70. "onselect", "onselectstart", "onselectionchange",
  71. "oncopy", "onbeforecopy",
  72. "onpaste", "onbeforepaste", "oncut", "onbeforecut",
  73. "onpointercancel", "onpointerdown", "onpointerenter", "onpointerleave", "onpointerlockchange", "onpointerlockerror", "onpointermove", "onpointerout", "onpointerover", "onpointerrawupdate", "onpointerup",
  74. ].forEach(xcanwin => {
  75. el[xcanwin] = e => {
  76. // 处理能影响文本的事件
  77. e.stopImmediatePropagation();
  78. }
  79. });
  80.  
  81. [
  82. "onmouseenter", "onmousedown", "onmouseup", "onmouseout", "onmouseleave", "onmouseover",
  83. ].forEach(xcanwin => {
  84. el[xcanwin] = e => {
  85. if ([ "P" ].indexOf(e.target.nodeName) >=0 && e.button == 0) {
  86. // 处理单击左键和滑动左键下的html文本标签
  87. e.stopImmediatePropagation();
  88. }
  89. }
  90. });
  91.  
  92. [
  93. "onkeypress", "onkeyup", "onkeydown",
  94. ].forEach(xcanwin => {
  95. el[xcanwin] = e => {
  96. const keyCode = e.keyCode || e.which || e.charCode;
  97. const ctrlKey = e.ctrlKey || e.metaKey;
  98. if ((ctrlKey && keyCode == 67) || keyCode == 123) {
  99. // 处理ctrl+c和F12
  100. e.stopImmediatePropagation();
  101. }
  102. }
  103. });
  104.  
  105. [
  106. "oncontextmenu",
  107. ].forEach(xcanwin => {
  108. el[xcanwin] = e => {
  109. if (e.target && e.target.points == undefined){
  110. // 处理普通的单击右键,跳过滑动右键
  111. e.stopImmediatePropagation();
  112. }
  113. }
  114. });
  115. });
  116.  
  117. try {
  118. console.clear = () => {};
  119. window.debugger = () => {};
  120. } catch (e) {
  121. }
  122. };
  123.  
  124. const switchAuto = () => {
  125. let autolist = JSON.parse(gv("ul_autolist", "[]"));
  126. const domain = getdomain();
  127. if (autolist.includes(domain)) {
  128. autolist = autolist.filter(el => el !== domain);
  129. } else {
  130. autolist.push(domain);
  131. }
  132. sv("ul_autolist", JSON.stringify(autolist));
  133. rmc();
  134. };
  135.  
  136. const showAuto = () => {
  137. prompt("自动破解列表", gv("ul_autolist", "[]"));
  138. };
  139.  
  140. const initAutoList = () => {
  141. const defaultal = ["blog.csdn.net","www.bilibili.com","360doc.com","guofeng.yuedu.163.com","kuwo.cn","chuangshi.qq.com","read.qidian.com","dafrok.github.io","shushan.zhangyue.net","aqistudy.cn","xuexila.com","51test.net","laokaoya.com","utaten.com","book.qq.com","doc.mbalib.com","oh100.com","51test.net","cspengbo.com","diyifanwen.com","ahsrst.cn","kt250.com"];
  142. if (!gv("ul_autolist", "[]")) {
  143. sv("ul_autolist", JSON.stringify(defaultal));
  144. }
  145. try {
  146. JSON.parse(gv("ul_autolist", "[]"));
  147. } catch (e) {
  148. sv("ul_autolist", JSON.stringify(defaultal));
  149. }
  150. };
  151.  
  152. const unrmc = () => {
  153. mc.forEach(x => GM_unregisterMenuCommand(x));
  154. };
  155.  
  156. const rmc = () => {
  157. unrmc();
  158. let isauto;
  159. initAutoList();
  160. const autolist = JSON.parse(gv("ul_autolist", "[]"));
  161. const domain = getdomain();
  162. if (autolist.includes(domain)) {
  163. isauto = 1;
  164. unLimit();
  165. } else {
  166. isauto = 0;
  167. }
  168. mc.push(GM_registerMenuCommand(`尝试破解`, unLimit));
  169. mc.push(GM_registerMenuCommand(`加入自动破解列表 ${symbol[isauto]}`, switchAuto));
  170. mc.push(GM_registerMenuCommand(`查看自动破解列表`, showAuto));
  171. };
  172.  
  173. const getdomain = () => {
  174. return (new URL(location.href)).hostname;
  175. };
  176.  
  177. let mc = []
  178. const symbol = "❌✔️";
  179. rmc();
  180.  
  181. })();