复制粘贴

解除网站不允许复制的限制

  1. // ==UserScript==
  2. // @name 复制粘贴
  3. // @description 解除网站不允许复制的限制
  4. // @version 1.0.1
  5. // @author cij81
  6. // @match *://wenku.baidu.com/view/*
  7. // @match *://wenku.baidu.com/share/*
  8. // @match *://wenku.baidu.com/link*
  9. // @match *://www.51test.net/show/*
  10. // @match *://www.xuexi.la/*
  11. // @match *://www.xuexila.com/*
  12. // @match *://www.cspengbo.com/*
  13. // @match *://*.doc88.com/*
  14. // @match *://segmentfault.com/*
  15. // @match *://wk.baidu.com/view/*
  16. // @match *://leetcode-cn.com/problems/*
  17. // @match *://www.zhihu.com/*
  18. // @match *://z.30edu.com.cn/*
  19. // @match *://docs.qq.com/doc/*
  20. // @match *://boke112.com/post/*
  21. // @match *://www.yuque.com/*
  22. // @match *://www.commandlinux.com/*
  23. // @match *://*.diyifanwen.com/*
  24. // @match *://*.mbalib.com/*
  25. // @match *://*.cnitpm.com/*
  26. // @match *://bbs.mihoyo.com/ys/obc/*
  27. // @match *://*.ruiwen.com/*
  28. // @match *://www.uemeds.cn/*
  29. // @match *://www.oh100.com/*
  30. // @match *://www.aiyuke.com/news/*
  31. // @match *://www.fwsir.com/*
  32. // @match *://www.wenxm.cn/*
  33. // @match *://www.unjs.com/*
  34. // @match *://www.ahsrst.cn/*
  35. // @match *://*.yjbys.com/*
  36. // @match *://*.qidian.com/*
  37. // @match *://*.zongheng.com/*
  38. // @match *://*.17k.com/*
  39. // @match *://*.ciweimao.com/*
  40. // @match *://book.qq.com/*
  41. // @match *://*.360doc.com/content/*
  42. // @match *://*.850500.com/news/*
  43. // @match *://utaten.com/lyric/*
  44. // @match *://*.jianbiaoku.com/*
  45. // @match *://*.kt250.com/*
  46. // @match *://www.kejudati.com/*
  47. // @match *://*.xiaohongshu.com/discovery/*
  48. // @match *://*.baibeike.com/*
  49. // @match *://*.blog.csdn.net/*
  50. // @match *://*.bilibili.com/read/*
  51. // @match *://*.cnki.net/KXReader/*
  52. // @match *://*.cnrencai.com/*
  53. // @match *://*.kodiplayer.cn/*
  54. // @match *://tongxiehui.net/*
  55. // @supportURL https://github.com/WindrunnerMax/TKScript/issues
  56. // @license GPL License
  57. // @run-at document-start
  58. // @require https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js
  59. // @require https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/clipboard.js/2.0.10/clipboard.min.js
  60. // @connect res3.doc88.com
  61. // @grant unsafeWindow
  62. // @grant GM_xmlhttpRequest
  63. // @namespace https://gf.qytechs.cn/users/919887
  64. // ==/UserScript==
  65. (function () {
  66. 'use strict';
  67.  
  68. function styleInject(css, ref) {
  69. if ( ref === void 0 ) ref = {};
  70. var insertAt = ref.insertAt;
  71.  
  72. if (!css || typeof document === 'undefined') { return; }
  73.  
  74. var head = document.head || document.getElementsByTagName('head')[0];
  75. var style = document.createElement('style');
  76. style.type = 'text/css';
  77.  
  78. if (insertAt === 'top') {
  79. if (head.firstChild) {
  80. head.insertBefore(style, head.firstChild);
  81. } else {
  82. head.appendChild(style);
  83. }
  84. } else {
  85. head.appendChild(style);
  86. }
  87.  
  88. if (style.styleSheet) {
  89. style.styleSheet.cssText = css;
  90. } else {
  91. style.appendChild(document.createTextNode(css));
  92. }
  93. }
  94.  
  95. var css_248z = "#_copy{align-items:center;background:#4c98f7;border-radius:3px;color:#fff;cursor:pointer;display:flex;font-size:13px;height:30px;justify-content:center;position:absolute;width:60px;z-index:1000}#select-tooltip,#sfModal,.modal-backdrop,div[id^=reader-helper]{display:none!important}.modal-open{overflow:auto!important}._sf_adjust_body{padding-right:0!important}";
  96. styleInject(css_248z);
  97.  
  98. var initEvent = function ($, websiteConfig) {
  99. document.addEventListener("DOMContentLoaded", function () {
  100. $("body").on("mousedown", function () { return $("#_copy").remove(); });
  101. if (websiteConfig.initCopyEvent) {
  102. document.oncopy = function (e) { return e.stopPropagation(); };
  103. document.body.oncopy = function (e) { return e.stopPropagation(); };
  104. $("body").on("copy", function (e) {
  105. e.stopPropagation();
  106. return true;
  107. });
  108. }
  109. });
  110. };
  111. var bindClipboardEvent = function (clipboard) {
  112. clipboard.on("success", function (e) {
  113. $("#_copy").html("复制成功");
  114. setTimeout(function () { return $("#_copy").fadeOut(1000); }, 1000);
  115. e.clearSelection();
  116. });
  117. clipboard.on("error", function (e) {
  118. $("#_copy").html("复制失败");
  119. setTimeout(function () { return $("#_copy").fadeOut(1000); }, 1000);
  120. e.clearSelection();
  121. });
  122. };
  123.  
  124. /**
  125. * 外部引用`static.doc88.com`声明
  126. * 此部分是在处理`doc88.com`才会加载的资源文件,此资源文件由该网站加载时提供
  127. */
  128. var path = "";
  129. var website$q = {
  130. regexp: /.*doc88\.com\/.+/,
  131. init: function ($) {
  132. // GM_xmlhttpRequest({
  133. // method: "GET",
  134. // url: "https://res.doc88.com/assets/js/v2.js",
  135. // onload: function(response) {
  136. // var view = new Function("var view = " + response.responseText.replace("eval", "") + "; return view;");
  137. // path = /<textarea[\s\S]*?Viewer.([\S]*?)\+[\S]*?\/textarea>/.exec(view())[1];
  138. // }
  139. // })
  140. $("body").append("<style id=\"copy-element-hide\">#left-menu{display: none !important;}</style>");
  141. GM_xmlhttpRequest({
  142. method: "GET",
  143. url: "https://res3.doc88.com/resources/js/modules/main-v2.min.js?v=2.56",
  144. onload: function (response) {
  145. var result = /\("#cp_textarea"\).val\(([\S]*?)\);/.exec(response.responseText);
  146. if (result)
  147. path = result[1];
  148. },
  149. });
  150. window.addEventListener("load", function () {
  151. var cpFn = unsafeWindow.copyText.toString();
  152. var fnResult = /<textarea[\s\S]*?>'\+([\S]*?)\+"<\/textarea>/.exec(cpFn);
  153. if (fnResult)
  154. path = fnResult[1];
  155. });
  156. },
  157. getSelectedText: function () {
  158. var select = unsafeWindow;
  159. path.split(".").forEach(function (v) {
  160. select = select[v];
  161. });
  162. if (!select) {
  163. unsafeWindow.Config.vip = 1;
  164. unsafeWindow.Config.logined = 1;
  165. $("#copy-element-hide").remove();
  166. }
  167. return select;
  168. },
  169. };
  170.  
  171. var website$p = {
  172. regexp: /.*segmentfault\.com\/.+/,
  173. init: function ($) {
  174. $("body").addClass("_sf_adjust_body");
  175. $("body").on("click", function () {
  176. $("body").css("padding-right", 0);
  177. });
  178. },
  179. };
  180.  
  181. var stopJQueryPropagation = function (event) {
  182. event.stopPropagation();
  183. // event.stopImmediatePropagation(); // 即停且阻止该元素后`on`同类事件触发
  184. return true; // 若为 `false` 则会 `preventDefault` `stopPropagation`
  185. };
  186. var stopNativePropagation = function (event) { return event.stopPropagation(); };
  187. var utils = {
  188. hideButton: function ($) {
  189. $("body").append("<style id=\"copy-hide\">#_copy{display: none !important;}</style>");
  190. },
  191. showButton: function ($) {
  192. $("#copy-hide").remove();
  193. },
  194. removeAttributes: function ($, selector, attr) {
  195. if (attr === void 0) { attr = []; }
  196. var dom = $(selector);
  197. attr.forEach(function (item) { return dom.removeAttr(item); });
  198. },
  199. enableUserSelect: function ($, selector, inline) {
  200. if (inline === void 0) { inline = false; }
  201. if (inline) {
  202. var cur = $(selector);
  203. cur.css("user-select", "auto");
  204. cur.css("-webkit-user-select", "auto");
  205. }
  206. else {
  207. var template = "\n <style>\n ".concat(selector, "{\n user-select: auto !important;\n -webkit-user-select: auto !important;\n }\n </style>\n ");
  208. $("body").append(template.replace(/\s*/, " "));
  209. }
  210. },
  211. enableOnSelectStart: function ($, selector) {
  212. $(selector).on("selectstart", stopJQueryPropagation);
  213. },
  214. enableOnContextMenu: function ($, selector) {
  215. $(selector).on("contextmenu", stopJQueryPropagation);
  216. },
  217. enableOnCopy: function ($, selector) {
  218. $(selector).on("copy", stopJQueryPropagation);
  219. },
  220. enableOnKeyDown: function ($, selector) {
  221. $(selector).on("keydown", function (e) {
  222. if (e.key === "c" && e.ctrlKey)
  223. return stopJQueryPropagation(e);
  224. });
  225. },
  226. enableOnSelectStartByCapture: function () {
  227. document.addEventListener("selectstart", stopNativePropagation, true);
  228. },
  229. enableOnContextMenuByCapture: function () {
  230. document.addEventListener("contextmenu", stopNativePropagation, true);
  231. },
  232. enableOnCopyByCapture: function () {
  233. document.addEventListener("copy", stopNativePropagation, true);
  234. },
  235. enableOnKeyDownByCapture: function () {
  236. document.addEventListener("keydown", stopNativePropagation, true);
  237. },
  238. };
  239.  
  240. var website$o = {
  241. regexp: /.*wk\.baidu\.com\/view\/.+/,
  242. init: function ($) {
  243. utils.hideButton($);
  244. $(window).on("load", function () {
  245. $(".sf-edu-wenku-vw-container").attr("style", "");
  246. $(".sfa-body").on("selectstart", function (e) {
  247. e.stopPropagation();
  248. return true;
  249. });
  250. });
  251. },
  252. };
  253.  
  254. var website$n = {
  255. regexp: /.*zhihu\.com\/.*/,
  256. init: function ($) {
  257. utils.hideButton($);
  258. },
  259. };
  260.  
  261. var website$m = {
  262. regexp: /.*zhihu\.com\/pub\/reader\/.+/,
  263. init: function ($) {
  264. setTimeout(utils.showButton, 500, $);
  265. },
  266. };
  267.  
  268. var website$l = {
  269. regexp: /.*30edu\.com\.cn\/.+/,
  270. init: function ($) {
  271. window.onload = function () {
  272. var iframes = document.getElementsByTagName("iframe");
  273. if (iframes.length === 2) {
  274. var body = $(iframes[1].contentWindow.document.querySelector("body"));
  275. body.attr("oncopy", "");
  276. body.attr("oncontextmenu", "");
  277. body.attr("onselectstart", "");
  278. }
  279. };
  280. },
  281. };
  282.  
  283. var restrictCopying = true;
  284. var website$k = {
  285. regexp: /.*docs\.qq\.com\/.+/,
  286. config: {
  287. initCopyEvent: false,
  288. },
  289. init: function ($) {
  290. window.onload = function () {
  291. if (unsafeWindow.pad) {
  292. if (unsafeWindow.pad.editor._docEnv.copyable === true) {
  293. // 不限制复制
  294. restrictCopying = false;
  295. utils.hideButton($);
  296. }
  297. else {
  298. unsafeWindow.pad.editor._docEnv.copyable = true;
  299. }
  300. }
  301. else {
  302. restrictCopying = false;
  303. utils.hideButton($);
  304. }
  305. };
  306. },
  307. getSelectedText: function () {
  308. if (!restrictCopying)
  309. return "";
  310. if (unsafeWindow.pad) {
  311. unsafeWindow.pad.editor._docEnv.copyable = true;
  312. unsafeWindow.pad.editor.clipboardManager.copy();
  313. return unsafeWindow.pad.editor.clipboardManager.customClipboard.plain;
  314. }
  315. return "";
  316. },
  317. };
  318.  
  319. var website$j = {
  320. regexp: new RegExp(".+://boke112.com/post/.+"),
  321. init: function ($) {
  322. $("body").on("click", function () { return false; });
  323. 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 ";
  324. $("body").append(template.replace(/\s*/, " "));
  325. },
  326. };
  327.  
  328. var website$i = {
  329. regexp: /diyifanwen/,
  330. init: function () {
  331. utils.hideButton($);
  332. utils.enableOnCopyByCapture();
  333. utils.enableOnKeyDownByCapture();
  334. },
  335. };
  336.  
  337. var website$h = {
  338. regexp: /mbalib/,
  339. init: function ($) {
  340. window.onload = function () {
  341. var container = $("#fullScreenContainer");
  342. container.attr("oncopy", "");
  343. container.attr("oncontextmenu", "");
  344. container.attr("onselectstart", "");
  345. };
  346. },
  347. };
  348.  
  349. var website$g = {
  350. regexp: /cnitpm/,
  351. init: function ($) {
  352. utils.hideButton($);
  353. window.onload = function () {
  354. var container = $("body");
  355. container.attr("oncopy", "");
  356. container.attr("oncontextmenu", "");
  357. container.attr("onselectstart", "");
  358. };
  359. },
  360. };
  361.  
  362. var website$f = {
  363. regexp: new RegExp(".+bbs.mihoyo.com/ys/obc.+"),
  364. init: function ($) {
  365. utils.hideButton($);
  366. $(".detail__content").on("copy", function (e) { return e.stopPropagation(); });
  367. var template = "\n <style>\n body{\n user-select: auto;\n -webkit-user-select: auto;\n }\n </style>\n ";
  368. $("body").append(template.replace(/\s*/, " "));
  369. },
  370. };
  371.  
  372. var website$e = {
  373. regexp: new RegExp(".+www.uemeds.cn/.+"),
  374. init: function ($) {
  375. utils.hideButton($);
  376. var template = "\n <style>\n .detail-main{\n user-select: auto;\n -webkit-user-select: auto;\n }\n </style>\n ";
  377. $("body").append(template.replace(/\s*/, " "));
  378. },
  379. };
  380.  
  381. var website$d = {
  382. regexp: new RegExp(".+aiyuke.com/news/.+"),
  383. init: function ($) {
  384. utils.hideButton($);
  385. $(".news_content_body").css("user-select", "auto");
  386. },
  387. };
  388.  
  389. var website$c = {
  390. regexp: new RegExp("qidian"),
  391. init: function ($) {
  392. utils.hideButton($);
  393. utils.enableUserSelect($, "body");
  394. utils.enableOnCopy($, ".main-read-container");
  395. utils.enableOnContextMenu($, ".main-read-container");
  396. },
  397. };
  398.  
  399. var website$b = {
  400. regexp: new RegExp("zongheng"),
  401. init: function ($) {
  402. utils.removeAttributes($, ".reader_box", ["style", "unselectable", "onselectstart"]);
  403. utils.removeAttributes($, ".reader_main", ["style", "unselectable", "onselectstart"]);
  404. utils.hideButton($);
  405. utils.enableOnKeyDown($, "body");
  406. utils.enableUserSelect($, ".reader_box .content p");
  407. utils.enableOnCopy($, ".content");
  408. utils.enableOnContextMenu($, "body");
  409. utils.enableOnSelectStart($, ".content");
  410. },
  411. };
  412.  
  413. var website$a = {
  414. regexp: new RegExp("17k"),
  415. init: function ($) {
  416. utils.hideButton($);
  417. utils.enableOnCopy($, ".readAreaBox .p");
  418. },
  419. };
  420.  
  421. var website$9 = {
  422. regexp: new RegExp("ciweimao"),
  423. init: function ($) {
  424. utils.hideButton($);
  425. utils.enableUserSelect($, "#J_BookRead");
  426. utils.enableOnCopy($, "#J_BookCnt");
  427. utils.enableOnContextMenu($, "body");
  428. utils.enableOnSelectStart($, "#J_BookCnt");
  429. },
  430. };
  431.  
  432. var website$8 = {
  433. regexp: new RegExp("book\\.qq"),
  434. init: function ($) {
  435. utils.hideButton($);
  436. utils.enableUserSelect($, "body");
  437. utils.enableOnCopy($, "body");
  438. utils.enableOnContextMenu($, "body");
  439. utils.enableOnSelectStart($, "body");
  440. },
  441. };
  442.  
  443. var website$7 = {
  444. regexp: new RegExp("utaten"),
  445. init: function ($) {
  446. utils.removeAttributes($, "body", ["oncontextmenu", "onselectstart"]);
  447. utils.hideButton($);
  448. utils.enableUserSelect($, ".lyricBody", true);
  449. },
  450. };
  451.  
  452. var website$6 = {
  453. config: {
  454. runAt: "document-start",
  455. },
  456. regexp: new RegExp("wenku.baidu.com/(view|link).*"),
  457. init: function ($) {
  458. $("head").append("<style>@media print { body{ display:block; } }</style>");
  459. var canvasDataGroup = [];
  460. var originObject = {
  461. context2DPrototype: unsafeWindow.document.createElement("canvas").getContext("2d")
  462. .__proto__,
  463. };
  464. document.createElement = new Proxy(document.createElement, {
  465. apply: function (target, thisArg, argumentsList) {
  466. var element = Reflect.apply(target, thisArg, argumentsList);
  467. if (argumentsList[0] === "canvas") {
  468. var tmpData_1 = {
  469. canvas: element,
  470. data: [],
  471. };
  472. element.getContext("2d").fillText = function () {
  473. var args = [];
  474. for (var _i = 0; _i < arguments.length; _i++) {
  475. args[_i] = arguments[_i];
  476. }
  477. tmpData_1.data.push(args);
  478. originObject.context2DPrototype.fillText.apply(this, args);
  479. };
  480. canvasDataGroup.push(tmpData_1);
  481. }
  482. return element;
  483. },
  484. });
  485. var pageData = {};
  486. Object.defineProperty(unsafeWindow, "pageData", {
  487. set: function (v) { return (pageData = v); },
  488. get: function () {
  489. if (!pageData.vipInfo)
  490. return (pageData.vipInfo = {});
  491. pageData.vipInfo.global_svip_status = 1;
  492. pageData.vipInfo.global_vip_status = 1;
  493. pageData.vipInfo.isVip = 1;
  494. pageData.vipInfo.isWenkuVip = 1;
  495. return pageData;
  496. },
  497. });
  498. var templateCSS = [
  499. "<style id='copy-template-css'>",
  500. "body{overflow: hidden !important}",
  501. "#copy-template-html{position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: flex; align-items: center; justify-content: center;z-index: 999999; background: rgba(0,0,0,0.5);}",
  502. "#copy-template-html > .template-container{height: 80%; width: 80%; background: #fff; }",
  503. ".template-container > .title-container{display: flex; align-items: center; justify-content: space-between;padding: 10px;border-bottom: 1px solid #eee;}",
  504. "#copy-template-text{height: 100%; width: 100%;position: relative; overflow: auto;background: #fff;}",
  505. "#copy-template-html #template-close{cursor: pointer;}",
  506. "</style>",
  507. ].join("");
  508. var render = function () {
  509. canvasDataGroup = canvasDataGroup.filter(function (item) { return item.canvas.id; });
  510. var templateText = canvasDataGroup.map(function (canvasData, index) {
  511. var computedTop = index * Number(canvasData.canvas.clientHeight);
  512. var textItem = canvasData.data.map(function (item) {
  513. return "<div style=\"position: absolute; left: ".concat(item[1], "px; top: ").concat(item[2] + computedTop, "px\">").concat(item[0], "</div>");
  514. });
  515. return textItem.join("");
  516. });
  517. var templateHTML = [
  518. "<div id='copy-template-html'>",
  519. "<div class='template-container'>",
  520. "<div class='title-container'>",
  521. "<div>请自行复制</div>",
  522. "<div id='template-close'>关闭</div>",
  523. "</div>",
  524. "<div id='copy-template-text'>",
  525. templateText.join(""),
  526. "</div>",
  527. "</div>",
  528. "</div>",
  529. ].join("");
  530. $("body").append(templateHTML);
  531. $("body").append(templateCSS);
  532. var closeButton = document.querySelector("#copy-template-html #template-close");
  533. var close = function () {
  534. $("#copy-template-html").remove();
  535. $("#copy-template-css").remove();
  536. closeButton.removeEventListener("click", close);
  537. };
  538. closeButton.addEventListener("click", close);
  539. };
  540. document.addEventListener("DOMContentLoaded", function () {
  541. $("head").append("<style>#copy-btn-wk{padding: 10px; background: rgba(0,0,0,0.5);position: fixed; left:0; top: 40%;cursor: pointer;color: #fff; z-index: 99999;}</style>");
  542. $("body").append("<div id='copy-btn-wk'>复制</div>");
  543. $("#copy-btn-wk").on("click", render);
  544. });
  545. },
  546. getSelectedText: function () {
  547. if (window.getSelection && window.getSelection().toString()) {
  548. return window.getSelection().toString();
  549. }
  550. var result = /查看全部包含“([\s\S]*?)”的文档/.exec(document.body.innerHTML);
  551. if (result)
  552. return result[1];
  553. return "";
  554. },
  555. };
  556.  
  557. var website$5 = {
  558. regexp: new RegExp("xiaohongshu"),
  559. init: function ($) {
  560. utils.hideButton($);
  561. utils.enableUserSelect($, "*");
  562. utils.enableOnKeyDownByCapture();
  563. },
  564. };
  565.  
  566. var website$4 = {
  567. regexp: new RegExp("leetcode"),
  568. init: function ($) {
  569. utils.hideButton($);
  570. utils.enableOnCopy($, "#lc-home");
  571. },
  572. };
  573.  
  574. var website$3 = {
  575. regexp: /csdn/,
  576. init: function ($) {
  577. utils.hideButton($);
  578. utils.enableOnCopyByCapture();
  579. utils.enableUserSelect($, "*");
  580. },
  581. };
  582.  
  583. var website$2 = {
  584. regexp: new RegExp("bilibili"),
  585. init: function ($) {
  586. utils.hideButton($);
  587. utils.enableOnCopyByCapture();
  588. },
  589. };
  590.  
  591. var website$1 = {
  592. regexp: new RegExp("cnki"),
  593. init: function ($) {
  594. utils.hideButton($);
  595. utils.enableOnContextMenuByCapture();
  596. utils.enableOnKeyDownByCapture();
  597. utils.enableOnCopyByCapture();
  598. },
  599. };
  600.  
  601. var website = {
  602. regexp: new RegExp([
  603. "commandlinux",
  604. "cnki",
  605. "ruiwen",
  606. "oh100",
  607. "fwsir",
  608. "wenxm",
  609. "unjs",
  610. "ahsrst",
  611. "yjbys",
  612. "360doc",
  613. "850500",
  614. "jianbiaoku",
  615. "kt250",
  616. "kejudati",
  617. "baibeike",
  618. "yuque",
  619. "cnrencai",
  620. "kodiplayer",
  621. "tongxiehui",
  622. ].join("|")),
  623. init: function ($) {
  624. utils.hideButton($);
  625. utils.enableUserSelect($, "*");
  626. utils.enableOnCopyByCapture();
  627. },
  628. };
  629.  
  630. var websites = [
  631. website$p,
  632. website$o,
  633. website$n,
  634. website$m,
  635. website$l,
  636. website$k,
  637. website$j,
  638. website$i,
  639. website$h,
  640. website$g,
  641. website$f,
  642. website$e,
  643. website$d,
  644. website$c,
  645. website$b,
  646. website$a,
  647. website$9,
  648. website$8,
  649. website$7,
  650. website$6,
  651. website$5,
  652. website$q,
  653. website$4,
  654. website$3,
  655. website$2,
  656. website$1,
  657. website,
  658. ];
  659.  
  660. var siteGetSelectedText = null;
  661. var initWebsite = function ($) {
  662. var websiteConfig = {
  663. initCopyEvent: true,
  664. runAt: "document-end",
  665. };
  666. var mather = function (regex, website) {
  667. if (regex.test(window.location.href)) {
  668. if (website.config)
  669. websiteConfig = Object.assign(websiteConfig, website.config);
  670. if (websiteConfig.runAt === "document-end") {
  671. document.addEventListener("DOMContentLoaded", function () { return website.init($); });
  672. }
  673. else {
  674. website.init($);
  675. }
  676. if (website.getSelectedText)
  677. siteGetSelectedText = website.getSelectedText;
  678. return true;
  679. }
  680. return false;
  681. };
  682. websites.some(function (website) { return mather(website.regexp, website); });
  683. return websiteConfig;
  684. };
  685. var getSelectedText = function () {
  686. if (siteGetSelectedText)
  687. return siteGetSelectedText();
  688. if (window.getSelection)
  689. return window.getSelection().toString();
  690. if (document.getSelection)
  691. return document.getSelection().toString();
  692. if (document.selection)
  693. return document.selection.createRange().text;
  694. return "";
  695. };
  696.  
  697. (function () {
  698. var $ = window.$;
  699. var ClipboardJS = window.ClipboardJS; // https://clipboardjs.com/#example-text
  700. var websiteConfig = initWebsite($);
  701. initEvent($, websiteConfig);
  702. document.addEventListener("mouseup", function (e) {
  703. var copyText = getSelectedText();
  704. if (copyText)
  705. console.log(copyText);
  706. else
  707. return "";
  708. $("#_copy").remove();
  709. 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 ");
  710. $("body").append(template);
  711. $("#_copy").on("mousedown", function (event) { return event.stopPropagation(); });
  712. $("#_copy").on("mouseup", function (event) { return event.stopPropagation(); });
  713. var clipboard = new ClipboardJS("#_copy");
  714. bindClipboardEvent(clipboard);
  715. });
  716. })();
  717. /**
  718. * https://www.huiyingwu.com/1718/
  719. */
  720.  
  721. })();

QingJ © 2025

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