🔥🔥🔥文本选中复制🔥🔥🔥

解除网站不允许复制的限制,文本选中后点击复制按钮即可复制,主要用于 百度文库 道客巴巴 无忧考网 学习啦 蓬勃范文 思否社区 力扣 知乎 语雀 等

目前为 2021-09-28 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 🔥🔥🔥文本选中复制🔥🔥🔥
  3. // @description 解除网站不允许复制的限制,文本选中后点击复制按钮即可复制,主要用于 百度文库 道客巴巴 无忧考网 学习啦 蓬勃范文 思否社区 力扣 知乎 语雀 等
  4. // @namespace https://github.com/WindrunnerMax/TKScript
  5. // @version 2.2.7
  6. // @author Czy
  7. // @include *://wenku.baidu.com/view/*
  8. // @include *://wenku.baidu.com/link*
  9. // @include *://www.51test.net/show/*
  10. // @include *://www.xuexi.la/*
  11. // @include *://www.xuexila.com/*
  12. // @include *://www.cspengbo.com/*
  13. // @include *://*.doc88.com/*
  14. // @include *://segmentfault.com/*
  15. // @include *://wk.baidu.com/view/*
  16. // @include *://leetcode-cn.com/problems/*
  17. // @include *://www.zhihu.com/*
  18. // @include *://z.30edu.com.cn/*
  19. // @include *://docs.qq.com/doc/*
  20. // @include *://boke112.com/post/*
  21. // @include *://www.yuque.com/*
  22. // @include *://www.commandlinux.com/*
  23. // @include *://*.diyifanwen.com/*
  24. // @include *://*.mbalib.com/*
  25. // @include *://*.cnitpm.com/*
  26. // @include *://bbs.mihoyo.com/ys/obc/*
  27. // @include *://www.ruiwen.com/*
  28. // @include *://www.uemeds.cn/*
  29. // @include *://www.oh100.com/*
  30. // @include *://www.aiyuke.com/news/*
  31. // @supportURL https://github.com/WindrunnerMax/TKScript/issues
  32. // @license GPL License
  33. // @run-at document-end
  34. // @require https://cdn.bootcss.com/jquery/2.1.2/jquery.min.js
  35. // @require https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js
  36. // @connect static.doc88.com
  37. // @grant unsafeWindow
  38. // @grant GM_xmlhttpRequest
  39. // ==/UserScript==
  40.  
  41. (function () {
  42. 'use strict';
  43.  
  44. function styleInject(css, ref) {
  45. if (ref === void 0) ref = {};
  46. var insertAt = ref.insertAt;
  47.  
  48. if (!css || typeof document === 'undefined') {
  49. return;
  50. }
  51.  
  52. var head = document.head || document.getElementsByTagName('head')[0];
  53. var style = document.createElement('style');
  54. style.type = 'text/css';
  55.  
  56. if (insertAt === 'top') {
  57. if (head.firstChild) {
  58. head.insertBefore(style, head.firstChild);
  59. } else {
  60. head.appendChild(style);
  61. }
  62. } else {
  63. head.appendChild(style);
  64. }
  65.  
  66. if (style.styleSheet) {
  67. style.styleSheet.cssText = css;
  68. } else {
  69. style.appendChild(document.createTextNode(css));
  70. }
  71. }
  72.  
  73. var css_248z = "#_copy{width:60px;height:30px;background:#4c98f7;color:#fff;position:absolute;z-index:1000;display:flex;justify-content:center;align-items:center;border-radius:3px;font-size:13px;cursor:pointer}#select-tooltip,#sfModal,.modal-backdrop,div[id^=reader-helper]{display:none!important}.modal-open{overflow:auto!important}._sf_adjust_body{padding-right:0!important}";
  74. styleInject(css_248z);
  75.  
  76. function initEvent($, ClipboardJS) {
  77. $("body").on("mousedown", function () {
  78. $("#_copy").remove();
  79. });
  80.  
  81. document.oncopy = function (e) {
  82. return e.stopPropagation();
  83. };
  84.  
  85. document.body.oncopy = function (e) {
  86. return e.stopPropagation();
  87. };
  88.  
  89. $("body").on("copy", function (e) {
  90. e.stopPropagation();
  91. return true;
  92. });
  93. ClipboardJS.prototype.on("success", function (e) {
  94. $("#_copy").html("复制成功");
  95. setTimeout(function () {
  96. return $("#_copy").fadeOut(1000);
  97. }, 1000);
  98. e.clearSelection();
  99. });
  100. ClipboardJS.prototype.on("error", function (e) {
  101. $("#_copy").html("复制失败");
  102. setTimeout(function () {
  103. return $("#_copy").fadeOut(1000);
  104. }, 1000);
  105. e.clearSelection();
  106. });
  107. }
  108.  
  109. var path = "";
  110. var website = {
  111. regexp: /.*doc88\.com\/.+/,
  112. init: function init($) {
  113. // GM_xmlhttpRequest({
  114. // method: "GET",
  115. // url: "https://res.doc88.com/assets/js/v2.js",
  116. // onload: function(response) {
  117. // var view = new Function("var view = " + response.responseText.replace("eval", "") + "; return view;");
  118. // path = /<textarea[\s\S]*?Viewer.([\S]*?)\+[\S]*?\/textarea>/.exec(view())[1];
  119. // }
  120. // })
  121. $("body").append("<style id=\"copy-hide\">#left-menu{display: none !important;}</style>");
  122. GM_xmlhttpRequest({
  123. method: "GET",
  124. url: "https://static.doc88.com/resources/js/modules/main-v2.min.js?v=2.78",
  125. onload: function onload(response) {
  126. path = /<textarea[\s\S]+>'\+([\S]*?)\+"<\/textarea>/.exec(response.responseText)[1];
  127. }
  128. });
  129. },
  130. getSelectedText: function getSelectedText() {
  131. var select = unsafeWindow;
  132. path.split(".").forEach(function (v) {
  133. select = select[v];
  134. });
  135. return select;
  136. }
  137. };
  138.  
  139. var website$1 = {
  140. regexp: /.*segmentfault\.com\/.+/,
  141. init: function init($) {
  142. $("body").addClass("_sf_adjust_body");
  143. $("body").on("click", function () {
  144. $("body").css("padding-right", 0);
  145. });
  146. }
  147. };
  148.  
  149. var website$2 = {
  150. regexp: new RegExp("commandlinux|cnki|leetcode-cn|ruiwen|oh100"),
  151. init: function init($) {
  152. $("body").append("<style id=\"copy-hide\">#_copy{display: none !important;}</style>");
  153. },
  154. hideButton: function hideButton($) {
  155. this.init($);
  156. },
  157. showButton: function showButton($) {
  158. $("#copy-hide").remove();
  159. }
  160. };
  161.  
  162. var website$3 = {
  163. regexp: /.*wk\.baidu\.com\/view\/.+/,
  164. init: function init($) {
  165. website$2.hideButton($);
  166. $(window).on("load", function () {
  167. $(".sf-edu-wenku-vw-container").attr("style", "");
  168. $(".sfa-body").on("selectstart", function (e) {
  169. e.stopPropagation();
  170. return true;
  171. });
  172. });
  173. }
  174. };
  175.  
  176. var website$4 = {
  177. regexp: /.*zhihu\.com\/.*/,
  178. init: function init($) {
  179. website$2.hideButton($);
  180. }
  181. };
  182.  
  183. var website$5 = {
  184. regexp: /.*zhihu\.com\/pub\/reader\/.+/,
  185. init: function init($) {
  186. setTimeout(website$2.showButton, 500, $);
  187. }
  188. };
  189.  
  190. var website$6 = {
  191. regexp: /.*30edu\.com\.cn\/.+/,
  192. init: function init($) {
  193. window.onload = function () {
  194. var iframes = document.getElementsByTagName("iframe");
  195.  
  196. if (iframes.length === 2) {
  197. var body = $(iframes[1].contentWindow.document.querySelector("body"));
  198. body.attr("oncopy", "");
  199. body.attr("oncontextmenu", "");
  200. body.attr("onselectstart", "");
  201. }
  202. };
  203. }
  204. };
  205.  
  206. var website$7 = {
  207. regexp: /.*docs\.qq\.com\/.+/,
  208. init: function init($) {
  209. var hide = function hide() {
  210. return website$2.hideButton($);
  211. };
  212.  
  213. if (unsafeWindow.pad) {
  214. if (unsafeWindow.pad.editor._docEnv.copyable === true) hide();
  215. unsafeWindow.pad.editor._docEnv.copyable = true;
  216. } else {
  217. hide();
  218. }
  219. },
  220. getSelectedText: function getSelectedText() {
  221. if (unsafeWindow.pad) {
  222. unsafeWindow.pad.editor.clipboardManager.copy();
  223. return unsafeWindow.pad.editor.clipboardManager.customClipboard.plain;
  224. }
  225.  
  226. return void 0;
  227. }
  228. };
  229.  
  230. var website$8 = {
  231. regexp: new RegExp(".+://boke112.com/post/.+"),
  232. init: function init($) {
  233. $("body").on("click", function () {
  234. return false;
  235. });
  236. var template = "\n <style>\n :not(input):not(textarea)::selection {\n background-color: #2440B3 !important;\n color: #fff !important;\n }\n\n :not(input):not(textarea)::-moz-selection {\n background-color: #2440B3 !important;\n color: #fff !important;\n }\n </style>\n ";
  237. $("body").append(template.replace(/\s*/, " "));
  238. }
  239. };
  240.  
  241. var website$9 = {
  242. regexp: /diyifanwen/,
  243. init: function init() {
  244. setTimeout(function () {
  245. document.oncopy = function (e) {
  246. return e.stopPropagation();
  247. };
  248.  
  249. document.body.oncopy = function (e) {
  250. return e.stopPropagation();
  251. };
  252. }, 1000);
  253. }
  254. };
  255.  
  256. var website$a = {
  257. regexp: /mbalib/,
  258. init: function init($) {
  259. window.onload = function () {
  260. var container = $("#fullScreenContainer");
  261. container.attr("oncopy", "");
  262. container.attr("oncontextmenu", "");
  263. container.attr("onselectstart", "");
  264. };
  265. }
  266. };
  267.  
  268. var website$b = {
  269. regexp: /cnitpm/,
  270. init: function init($) {
  271. website$2.hideButton($);
  272.  
  273. window.onload = function () {
  274. var container = $("body");
  275. container.attr("oncopy", "");
  276. container.attr("oncontextmenu", "");
  277. container.attr("onselectstart", "");
  278. };
  279. }
  280. };
  281.  
  282. var website$c = {
  283. regexp: new RegExp(".+bbs.mihoyo.com/ys/obc.+"),
  284. init: function init($) {
  285. website$2.hideButton($);
  286. $(".detail__content").on("copy", function (e) {
  287. return e.stopPropagation();
  288. });
  289. var template = "\n <style>\n body{\n user-select: auto;\n -webkit-user-select: auto;\n }\n </style>\n ";
  290. $("body").append(template.replace(/\s*/, " "));
  291. }
  292. };
  293.  
  294. var website$d = {
  295. regexp: new RegExp(".+www.uemeds.cn/.+"),
  296. init: function init($) {
  297. website$2.hideButton($);
  298. var template = "\n <style>\n .detail-main{\n user-select: auto;\n -webkit-user-select: auto;\n }\n </style>\n ";
  299. $("body").append(template.replace(/\s*/, " "));
  300. }
  301. };
  302.  
  303. var website$e = {
  304. regexp: new RegExp(".+aiyuke.com/news/.+"),
  305. init: function init($) {
  306. website$2.hideButton($);
  307. $(".news_content_body").css("user-select", "auto");
  308. }
  309. };
  310.  
  311. var siteGetSelectedText = null;
  312. var modules = [website, website$1, website$3, website$4, website$5, website$6, website$7, website$8, website$9, website$a, website$b, website$c, website$d, website$e, website$2];
  313.  
  314. function initWebsite($) {
  315. var mather = function mather(regex, site) {
  316. if (regex.test(window.location.href)) {
  317. for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  318. args[_key - 2] = arguments[_key];
  319. }
  320.  
  321. site.init.apply(site, args);
  322. if (site.getSelectedText) siteGetSelectedText = site.getSelectedText;
  323. }
  324. };
  325.  
  326. modules.forEach(function (v) {
  327. return mather(v.regexp, v, $);
  328. });
  329. }
  330.  
  331. function getSelectedText() {
  332. if (siteGetSelectedText) return siteGetSelectedText();
  333. if (window.getSelection) return window.getSelection().toString();else if (document.getSelection) return document.getSelection();else if (document.selection) return document.selection.createRange().text;
  334. return "";
  335. }
  336.  
  337. (function () {
  338. var $ = window.$;
  339. var ClipboardJS = window.ClipboardJS; // https://clipboardjs.com/#example-text
  340.  
  341. initEvent($, ClipboardJS);
  342. initWebsite($);
  343. document.addEventListener("mouseup", function (e) {
  344. var copyText = getSelectedText();
  345. if (copyText) console.log(copyText);else return "";
  346. $("#_copy").remove();
  347. var template = "\n <div id=\"_copy\"\n style=\"left:".concat(e.pageX + 30, "px;top:").concat(e.pageY, "px;\"\n data-clipboard-text=\"").concat(copyText.replace(/"/g, "&quot;"), "\">\u590D\u5236</div>\n ");
  348. $("body").append(template);
  349. $("#_copy").on("mousedown", function (event) {
  350. event.stopPropagation();
  351. });
  352. $("#_copy").on("mouseup", function (event) {
  353. event.stopPropagation();
  354. });
  355. new ClipboardJS('#_copy');
  356. });
  357. })();
  358. /**
  359. * http://wenku.baiduvvv.com/
  360. * https://www.huiyingwu.com/1718/
  361. */
  362.  
  363. }());

QingJ © 2025

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