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

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

目前为 2023-06-17 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 🔥🔥🔥文本选中复制🔥🔥🔥
  3. // @description 解除网站不允许复制的限制,文本选中后点击复制按钮即可复制,主要用于 百度文库 道客巴巴 腾讯文档 豆丁网 无忧考网 学习啦 蓬勃范文 思否社区 力扣 知乎 语雀 等
  4. // @namespace https://github.com/WindrunnerMax/TKScript
  5. // @version 6.1.14
  6. // @author Czy
  7. // @match *://wenku.baidu.com/view/*
  8. // @match *://wenku.baidu.com/share/*
  9. // @match *://wenku.baidu.com/link*
  10. // @match *://wenku.baidu.com/aggs/*
  11. // @match *://wenku.baidu.com/ndPureView/*
  12. // @match *://www.51test.net/show/*
  13. // @match *://www.xuexi.la/*
  14. // @match *://www.xuexila.com/*
  15. // @match *://www.cspengbo.com/*
  16. // @match *://*.doc88.com/*
  17. // @match *://segmentfault.com/*
  18. // @match *://wk.baidu.com/view/*
  19. // @match *://leetcode-cn.com/problems/*
  20. // @match *://www.zhihu.com/*
  21. // @match *://z.30edu.com.cn/*
  22. // @match *://docs.qq.com/doc/*
  23. // @match *://boke112.com/post/*
  24. // @match *://*.yuque.com/*
  25. // @match *://www.commandlinux.com/*
  26. // @match *://*.diyifanwen.com/*
  27. // @match *://*.mbalib.com/*
  28. // @match *://*.cnitpm.com/*
  29. // @match *://bbs.mihoyo.com/ys/*
  30. // @match *://*.ruiwen.com/*
  31. // @match *://www.uemeds.cn/*
  32. // @match *://www.oh100.com/*
  33. // @match *://www.aiyuke.com/news/*
  34. // @match *://www.fwsir.com/*
  35. // @match *://www.wenxm.cn/*
  36. // @match *://www.unjs.com/*
  37. // @match *://www.ahsrst.cn/*
  38. // @match *://*.yjbys.com/*
  39. // @match *://*.qidian.com/*
  40. // @match *://*.zongheng.com/*
  41. // @match *://*.17k.com/*
  42. // @match *://*.ciweimao.com/*
  43. // @match *://book.qq.com/*
  44. // @match *://*.360doc.com/content/*
  45. // @match *://*.850500.com/news/*
  46. // @match *://utaten.com/lyric/*
  47. // @match *://*.jianbiaoku.com/*
  48. // @match *://*.kt250.com/*
  49. // @match *://www.kejudati.com/*
  50. // @match *://*.xiaohongshu.com/discovery/*
  51. // @match *://*.baibeike.com/*
  52. // @match *://*.blog.csdn.net/*
  53. // @match *://*.bilibili.com/read/*
  54. // @match *://*.cnki.net/KXReader/*
  55. // @match *://*.cnrencai.com/*
  56. // @match *://*.kodiplayer.cn/*
  57. // @match *://tongxiehui.net/*
  58. // @match *://*.jianshu.com/p/*
  59. // @match *://*.linovelib.com/novel/*
  60. // @match *://*.wjx.cn/*
  61. // @match *://*.wjx.top/*
  62. // @match *://*.chazidian.com/*
  63. // @match *://*.juejin.cn/post/*
  64. // @match *://*.zgbk.com/ecph/*
  65. // @match *://*.wenmi.com/article/*
  66. // @match *://yuedu.baidu.com/*
  67. // @match *://www.inrrp.com.cn/*
  68. // @match *://fanyi.baidu.com/mtpe/*
  69. // @match *://www.shubaoc.com/*
  70. // @match *://blog.51cto.com/*
  71. // @match *://www.ximalaya.com/*
  72. // @match *://*.tianqi.com/*
  73. // @match *://*.xiexiebang.com/*
  74. // @match *://*.docin.com/*
  75. // @match *://*.ddwk8.cn/*
  76. // @match *://*.php.cn/*
  77. // @match *://cooco.net.cn/*
  78. // @match *://fanqienovel.com/*
  79. // @match *://*.mobiletrain.org/*
  80. // @match *://*.examcoo.com/*
  81. // @match *://*.rrdynb.com/*
  82. // @match *://*.fuwu7.com/*
  83. // @match *://*.xiangqiqipu.com/*
  84. // @match *://note.youdao.com/*
  85. // @supportURL https://github.com/WindrunnerMax/TKScript/issues
  86. // @license GPL License
  87. // @run-at document-start
  88. // @connect res3.doc88.com
  89. // @grant unsafeWindow
  90. // @grant GM_xmlhttpRequest
  91. // ==/UserScript==
  92. (function () {
  93. 'use strict';
  94.  
  95. var css_248z$1 = ".__copy-button{align-items:center;background:#4c98f7;border-radius:3px;color:#fff;cursor:pointer;display:flex;font-size:13px;height:30px;justify-content:center;opacity:0;position:absolute;transition:opacity .3s;width:60px;z-index:-1000}";
  96.  
  97. var css_248z = "#select-tooltip,#sfModal,.modal-backdrop,div[id^=reader-helper]{display:none!important}.modal-open{overflow:auto!important}._sf_adjust_body{padding-right:0!important}";
  98.  
  99. const DOM_STAGE = {
  100. START: "document-start",
  101. END: "document-end"
  102. };
  103. const DOM_READY = "DOMContentLoaded";
  104. const PAGE_LOADED = "load";
  105. const MOUSE_UP = "mouseup";
  106. const MOUSE_DOWN = "mousedown";
  107. const MOUSE_MOVE = "mousemove";
  108. const COPY = "copy";
  109. const SELECT_START = "selectstart";
  110. const CONTEXT_MENU = "contextmenu";
  111. const KEY_DOWN = "keydown";
  112.  
  113. const opt = Object.prototype.toString;
  114. function isString(value) {
  115. return opt.call(value) === "[object String]";
  116. }
  117.  
  118. const dom$1 = {
  119. query: function(selector) {
  120. return document.querySelector(selector);
  121. },
  122. attr: function(selector, attr, value) {
  123. const dom2 = document.querySelector(selector);
  124. dom2 && dom2.setAttribute(attr, value);
  125. },
  126. append: function(selector, content) {
  127. const container = document.createElement("div");
  128. if (isString(content)) {
  129. container.innerHTML = content;
  130. } else {
  131. container.appendChild(content);
  132. }
  133. const targetDOM = document.querySelector(selector);
  134. targetDOM && targetDOM.append(container);
  135. return container;
  136. },
  137. remove: function(selector) {
  138. const targetDOM = document.querySelector(selector);
  139. targetDOM && targetDOM.remove();
  140. }
  141. };
  142.  
  143. const initBaseEvent = (websiteConfig) => {
  144. window.addEventListener(DOM_READY, () => {
  145. if (websiteConfig.initCopyEvent) {
  146. document.oncopy = (e) => e.stopPropagation();
  147. document.body.oncopy = (e) => e.stopPropagation();
  148. document.addEventListener(COPY, (e) => e.stopPropagation());
  149. document.body.addEventListener(COPY, (e) => e.stopPropagation());
  150. }
  151. });
  152. };
  153. const initBaseStyle = () => {
  154. window.addEventListener(DOM_READY, () => {
  155. dom$1.append("head", `<style>${css_248z$1}</style>`);
  156. dom$1.append("head", `<style>${css_248z}</style>`);
  157. });
  158. };
  159.  
  160. /*!
  161. * 外部引用`static.doc88.com`声明
  162. * 此部分是在处理`doc88.com`才会加载的资源文件,此资源文件由该网站加载时提供
  163. */
  164. let path = "";
  165. const website$t = {
  166. regexp: /.*doc88\.com\/.+/,
  167. init: () => {
  168. dom$1.append(
  169. "body",
  170. `<style id="copy-element-hide">#left-menu{display: none !important;}</style>`
  171. );
  172. GM_xmlhttpRequest({
  173. method: "GET",
  174. url: "https://res3.doc88.com/resources/js/modules/main-v2.min.js?v=2.56",
  175. onload: function(response) {
  176. const result = /\("#cp_textarea"\).val\(([\S]*?)\);/.exec(response.responseText);
  177. if (result)
  178. path = result[1];
  179. }
  180. });
  181. window.addEventListener("load", () => {
  182. const cpFn = unsafeWindow.copyText.toString();
  183. const fnResult = /<textarea[\s\S]*?>'\+([\S]*?)\+"<\/textarea>/.exec(cpFn);
  184. if (fnResult)
  185. path = fnResult[1];
  186. });
  187. },
  188. getSelectedText: () => {
  189. let select = unsafeWindow;
  190. path.split(".").forEach((v) => {
  191. select = select[v];
  192. });
  193. if (!select) {
  194. unsafeWindow.Config.vip = 1;
  195. unsafeWindow.Config.logined = 1;
  196. dom$1.remove("#copy-element-hide");
  197. }
  198. return select;
  199. }
  200. };
  201.  
  202. const website$s = {
  203. regexp: /.*segmentfault\.com\/.+/,
  204. init: function() {
  205. const body = dom$1.query("body");
  206. body.classList.add("_sf_adjust_body");
  207. body.onclick = () => {
  208. body.style.paddingRight = "0";
  209. };
  210. }
  211. };
  212.  
  213. const TEXT_PLAIN = "text/plain";
  214. const TEXT_HTML = "text/html";
  215. const downgradeCopy = (data) => {
  216. const textarea = document.createElement("textarea");
  217. textarea.addEventListener(
  218. COPY,
  219. (event) => {
  220. for (const [key, value] of Object.entries(data)) {
  221. event.clipboardData.setData(key, value);
  222. }
  223. event.stopPropagation();
  224. event.preventDefault();
  225. },
  226. true
  227. );
  228. textarea.style.position = "fixed";
  229. textarea.style.left = "-999px";
  230. textarea.style.top = "-999px";
  231. textarea.value = data[TEXT_PLAIN];
  232. document.body.appendChild(textarea);
  233. textarea.select();
  234. document.execCommand("copy");
  235. document.body.removeChild(textarea);
  236. };
  237. const isEmptyContent = (data) => {
  238. return isString(data) ? !data : !data[TEXT_PLAIN];
  239. };
  240. const copy = (data) => {
  241. const params = isString(data) ? { [TEXT_PLAIN]: data } : data;
  242. const plainText = params[TEXT_PLAIN];
  243. if (!plainText)
  244. return false;
  245. if (navigator.clipboard && window.ClipboardItem) {
  246. const dataItems = {};
  247. for (const [key, value] of Object.entries(params)) {
  248. const blob = new Blob([value], { type: key });
  249. dataItems[key] = blob;
  250. }
  251. navigator.clipboard.write([new ClipboardItem(dataItems)]).catch(() => {
  252. downgradeCopy(params);
  253. });
  254. } else {
  255. downgradeCopy(params);
  256. }
  257. return true;
  258. };
  259.  
  260. let dom = null;
  261. let isReadyToHidden = false;
  262. const instance = {
  263. id: "__copy",
  264. className: "__copy-button",
  265. getInstance: function() {
  266. if (dom === null) {
  267. const container = document.createElement("div");
  268. container.id = this.id;
  269. container.className = this.className;
  270. container.innerText = "复制";
  271. container.addEventListener("mouseup", (e) => e.stopPropagation(), true);
  272. container.addEventListener("mousedown", (e) => e.stopPropagation(), true);
  273. dom = container;
  274. document.body.appendChild(dom);
  275. }
  276. return dom;
  277. },
  278. show: function(event) {
  279. if (isReadyToHidden)
  280. return void 0;
  281. const dom2 = this.getInstance();
  282. dom2.style.left = `${event.pageX + 30}px`;
  283. dom2.style.top = `${event.pageY}px`;
  284. dom2.style.opacity = "1";
  285. dom2.style.zIndex = "1000";
  286. },
  287. hide: function() {
  288. const dom2 = this.getInstance();
  289. dom2.style.opacity = "0";
  290. isReadyToHidden = true;
  291. setTimeout(() => {
  292. dom2.style.zIndex = "-10000";
  293. isReadyToHidden = false;
  294. }, 350);
  295. },
  296. onCopy: function(content, event) {
  297. const dom2 = this.getInstance();
  298. this.show(event);
  299. dom2.onclick = () => {
  300. copy(content);
  301. this.hide();
  302. };
  303. },
  304. enable: function() {
  305. const dom2 = this.getInstance();
  306. dom2.style.display = "flex";
  307. },
  308. disable: function() {
  309. const dom2 = this.getInstance();
  310. dom2.style.display = "none";
  311. }
  312. };
  313.  
  314. const stopNativePropagation = (event) => {
  315. event.stopPropagation();
  316. };
  317. var utils = {
  318. hideButton: () => {
  319. instance.disable();
  320. },
  321. showButton: () => {
  322. instance.enable();
  323. },
  324. removeAttributes: (selector, attr = []) => {
  325. const dom = isString(selector) ? document.querySelector(selector) : selector;
  326. dom && attr.forEach((item) => dom.removeAttribute(item));
  327. },
  328. enableUserSelectByCSS: () => {
  329. const css = "*{user-select: auto !important;-webkit-user-select: auto !important;}";
  330. const style = document.createElement("style");
  331. style.innerText = css;
  332. const head = document.getElementsByTagName("head")[0];
  333. if (head) {
  334. head.appendChild(style);
  335. } else {
  336. window.addEventListener(
  337. PAGE_LOADED,
  338. () => document.getElementsByTagName("head")[0].appendChild(style)
  339. );
  340. }
  341. },
  342. enableOnSelectStart: (selector) => {
  343. const dom = document.querySelector(selector);
  344. dom && dom.addEventListener(SELECT_START, stopNativePropagation);
  345. },
  346. enableOnContextMenu: (selector) => {
  347. const dom = document.querySelector(selector);
  348. dom && dom.addEventListener(CONTEXT_MENU, stopNativePropagation);
  349. },
  350. enableOnCopy: (selector) => {
  351. const dom = document.querySelector(selector);
  352. dom && dom.addEventListener(COPY, stopNativePropagation);
  353. },
  354. enableOnKeyDown: (selector) => {
  355. const dom = document.querySelector(selector);
  356. dom && dom.addEventListener(KEY_DOWN, (e) => {
  357. if (e.key === "c" && e.ctrlKey)
  358. return e.stopPropagation();
  359. });
  360. },
  361. enableOnSelectStartByCapture: () => {
  362. window.addEventListener(SELECT_START, stopNativePropagation, true);
  363. document.addEventListener(SELECT_START, stopNativePropagation, true);
  364. },
  365. enableOnContextMenuByCapture: () => {
  366. window.addEventListener(CONTEXT_MENU, stopNativePropagation, true);
  367. document.addEventListener(CONTEXT_MENU, stopNativePropagation, true);
  368. },
  369. enableOnCopyByCapture: () => {
  370. window.addEventListener(COPY, stopNativePropagation, true);
  371. document.addEventListener(COPY, stopNativePropagation, true);
  372. },
  373. enableOnKeyDownByCapture: () => {
  374. document.addEventListener(
  375. KEY_DOWN,
  376. (e) => e.ctrlKey && e.key.toLocaleUpperCase() === "C" && e.stopPropagation(),
  377. true
  378. );
  379. }
  380. };
  381.  
  382. const website$r = {
  383. regexp: /.*wk\.baidu\.com\/view\/.+/,
  384. init: function() {
  385. utils.hideButton();
  386. utils.enableOnSelectStartByCapture();
  387. window.onload = () => {
  388. dom$1.attr(".sf-edu-wenku-vw-container", "style", "");
  389. };
  390. }
  391. };
  392.  
  393. const website$q = {
  394. regexp: /.*zhihu\.com\/.*/,
  395. init: function() {
  396. utils.hideButton();
  397. utils.enableUserSelectByCSS();
  398. utils.enableOnCopyByCapture();
  399. }
  400. };
  401.  
  402. const website$p = {
  403. regexp: /.*30edu\.com\.cn\/.+/,
  404. init: function() {
  405. window.onload = () => {
  406. const iframes = document.getElementsByTagName("iframe");
  407. if (iframes.length === 2) {
  408. const body = iframes[1].contentWindow.document.querySelector("body");
  409. utils.removeAttributes(body, ["oncopy", "oncontextmenu", "onselectstart"]);
  410. }
  411. };
  412. }
  413. };
  414.  
  415. const website$o = {
  416. regexp: /.*docs\.qq\.com\/.+/,
  417. config: {
  418. initCopyEvent: false
  419. },
  420. init: function() {
  421. window.onload = () => {
  422. utils.hideButton();
  423. };
  424. },
  425. getSelectedText: function() {
  426. if (unsafeWindow.pad && unsafeWindow.pad.editor && !unsafeWindow.pad.editor.isCopyable()) {
  427. utils.showButton();
  428. const editor = unsafeWindow.pad.editor;
  429. editor._docEnv.copyable = true;
  430. editor.clipboardManager.copy();
  431. const plainText = editor.clipboardManager.customClipboard.plain;
  432. const htmlText = editor.clipboardManager.customClipboard.html;
  433. editor._docEnv.copyable = false;
  434. return {
  435. [TEXT_PLAIN]: plainText,
  436. [TEXT_HTML]: htmlText
  437. };
  438. }
  439. return "";
  440. }
  441. };
  442.  
  443. const website$n = {
  444. regexp: new RegExp(".+://boke112.com/post/.+"),
  445. init: function() {
  446. utils.enableOnCopyByCapture();
  447. const template = `
  448. <style>
  449. :not(input):not(textarea)::selection {
  450. background-color: #2440B3 !important;
  451. color: #fff !important;
  452. }
  453.  
  454. :not(input):not(textarea)::-moz-selection {
  455. background-color: #2440B3 !important;
  456. color: #fff !important;
  457. }
  458. </style>
  459. `;
  460. dom$1.append("head", template);
  461. }
  462. };
  463.  
  464. const website$m = {
  465. regexp: /diyifanwen/,
  466. init: function() {
  467. utils.hideButton();
  468. utils.enableOnCopyByCapture();
  469. utils.enableOnKeyDownByCapture();
  470. }
  471. };
  472.  
  473. const website$l = {
  474. regexp: /mbalib/,
  475. init: function() {
  476. window.onload = () => {
  477. utils.removeAttributes("fullScreenContainer", [
  478. "oncopy",
  479. "oncontextmenu",
  480. "onselectstart"
  481. ]);
  482. };
  483. }
  484. };
  485.  
  486. const website$k = {
  487. regexp: /cnitpm/,
  488. init: function() {
  489. utils.hideButton();
  490. window.onload = () => {
  491. utils.removeAttributes("body", ["oncopy", "oncontextmenu", "onselectstart"]);
  492. };
  493. }
  494. };
  495.  
  496. const website$j = {
  497. regexp: new RegExp(".+bbs.mihoyo.com/.+"),
  498. init: function() {
  499. utils.hideButton();
  500. utils.enableOnCopyByCapture();
  501. utils.enableOnSelectStartByCapture();
  502. utils.enableUserSelectByCSS();
  503. }
  504. };
  505.  
  506. const website$i = {
  507. regexp: new RegExp(".+www.uemeds.cn/.+"),
  508. init: function() {
  509. utils.hideButton();
  510. utils.enableUserSelectByCSS();
  511. }
  512. };
  513.  
  514. const website$h = {
  515. regexp: new RegExp(".+aiyuke.com/news/.+"),
  516. init: function() {
  517. utils.hideButton();
  518. utils.enableUserSelectByCSS();
  519. }
  520. };
  521.  
  522. const website$g = {
  523. regexp: new RegExp("qidian"),
  524. init: function() {
  525. utils.hideButton();
  526. utils.enableUserSelectByCSS();
  527. utils.enableOnCopy(".main-read-container");
  528. utils.enableOnContextMenu(".main-read-container");
  529. }
  530. };
  531.  
  532. const website$f = {
  533. regexp: new RegExp("zongheng"),
  534. init: function() {
  535. utils.removeAttributes(".reader_box", ["style", "unselectable", "onselectstart"]);
  536. utils.removeAttributes(".reader_main", ["style", "unselectable", "onselectstart"]);
  537. utils.hideButton();
  538. utils.enableOnKeyDown("body");
  539. utils.enableUserSelectByCSS();
  540. utils.enableOnCopy(".content");
  541. utils.enableOnContextMenu("body");
  542. utils.enableOnSelectStart(".content");
  543. }
  544. };
  545.  
  546. const website$e = {
  547. regexp: new RegExp("17k"),
  548. init: () => {
  549. utils.hideButton();
  550. utils.enableOnCopy(".readAreaBox .p");
  551. }
  552. };
  553.  
  554. const website$d = {
  555. regexp: new RegExp("ciweimao"),
  556. init: function() {
  557. utils.hideButton();
  558. utils.enableUserSelectByCSS();
  559. utils.enableOnCopy("#J_BookCnt");
  560. utils.enableOnContextMenu("body");
  561. utils.enableOnSelectStart("#J_BookCnt");
  562. }
  563. };
  564.  
  565. const website$c = {
  566. regexp: new RegExp("book\\.qq"),
  567. init: function() {
  568. utils.hideButton();
  569. utils.enableOnCopy("body");
  570. utils.enableUserSelectByCSS();
  571. utils.enableOnContextMenu("body");
  572. utils.enableOnSelectStart("body");
  573. }
  574. };
  575.  
  576. const website$b = {
  577. regexp: new RegExp("utaten"),
  578. init: function() {
  579. utils.hideButton();
  580. utils.enableUserSelectByCSS();
  581. utils.enableOnSelectStartByCapture();
  582. }
  583. };
  584.  
  585. const website$a = {
  586. config: {
  587. runAt: "document-start"
  588. },
  589. regexp: new RegExp("wenku.baidu.com/(view|link|aggs).*"),
  590. init: function() {
  591. dom$1.append("head", `<style>@media print { body{ display:block; } }</style>`);
  592. let canvasDataGroup = [];
  593. const originObject = {
  594. context2DPrototype: unsafeWindow.document.createElement("canvas").getContext("2d").__proto__
  595. };
  596. document.createElement = new Proxy(document.createElement, {
  597. apply: function(target, thisArg, argumentsList) {
  598. const element = Reflect.apply(target, thisArg, argumentsList);
  599. if (argumentsList[0] === "canvas") {
  600. const tmpData = {
  601. canvas: element,
  602. data: []
  603. };
  604. element.getContext("2d").fillText = function(...args) {
  605. tmpData.data.push(args);
  606. originObject.context2DPrototype.fillText.apply(this, args);
  607. };
  608. canvasDataGroup.push(tmpData);
  609. }
  610. return element;
  611. }
  612. });
  613. let pageData = {};
  614. Object.defineProperty(unsafeWindow, "pageData", {
  615. set: (v) => pageData = v,
  616. get: function() {
  617. if (!pageData.vipInfo)
  618. return pageData.vipInfo = {};
  619. pageData.vipInfo.global_svip_status = 1;
  620. pageData.vipInfo.global_vip_status = 1;
  621. pageData.vipInfo.isVip = 1;
  622. pageData.vipInfo.isWenkuVip = 1;
  623. return pageData;
  624. }
  625. });
  626. const templateCSS = [
  627. "<style id='copy-template-css'>",
  628. "body{overflow: hidden !important}",
  629. "#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);}",
  630. "#copy-template-html > .template-container{height: 80%; width: 80%; background: #fff; }",
  631. ".template-container > .title-container{display: flex; align-items: center; justify-content: space-between;padding: 10px;border-bottom: 1px solid #eee;}",
  632. "#copy-template-text{height: 100%; width: 100%;position: relative; overflow: auto;background: #fff;}",
  633. "#copy-template-html #template-close{cursor: pointer;}",
  634. "</style>"
  635. ].join("");
  636. const render = () => {
  637. canvasDataGroup = canvasDataGroup.filter((item) => item.canvas.id);
  638. const templateText = canvasDataGroup.map((canvasData, index) => {
  639. const computedTop = index * Number(canvasData.canvas.clientHeight);
  640. const textItem = canvasData.data.map(
  641. (item) => `<div style="position: absolute; left: ${item[1]}px; top: ${item[2] + computedTop}px">${item[0]}</div>`
  642. );
  643. return textItem.join("");
  644. });
  645. const templateHTML = [
  646. "<div id='copy-template-html'>",
  647. "<div class='template-container'>",
  648. "<div class='title-container'>",
  649. "<div>请自行复制</div>",
  650. "<div id='template-close'>关闭</div>",
  651. "</div>",
  652. "<div id='copy-template-text'>",
  653. templateText.join(""),
  654. "</div>",
  655. "</div>",
  656. "</div>"
  657. ].join("");
  658. dom$1.append("body", templateHTML);
  659. dom$1.append("body", templateCSS);
  660. const closeButton = document.querySelector("#copy-template-html #template-close");
  661. const close = () => {
  662. dom$1.remove("#copy-template-html");
  663. dom$1.remove("#copy-template-css");
  664. closeButton.removeEventListener("click", close);
  665. };
  666. closeButton.addEventListener("click", close);
  667. };
  668. document.addEventListener("DOMContentLoaded", () => {
  669. dom$1.append(
  670. "head",
  671. `<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>`
  672. );
  673. dom$1.append("body", "<div id='copy-btn-wk'>复制</div>");
  674. const btn = dom$1.query("#copy-btn-wk");
  675. btn && (btn.onclick = render);
  676. });
  677. },
  678. getSelectedText: () => {
  679. if (window.getSelection && window.getSelection().toString()) {
  680. return window.getSelection().toString();
  681. }
  682. const result = /查看全部包含“([\s\S]*?)”的文档/.exec(document.body.innerHTML);
  683. if (result)
  684. return result[1];
  685. return "";
  686. }
  687. };
  688.  
  689. const website$9 = {
  690. regexp: new RegExp("xiaohongshu"),
  691. init: function() {
  692. utils.hideButton();
  693. utils.enableUserSelectByCSS();
  694. utils.enableOnKeyDownByCapture();
  695. }
  696. };
  697.  
  698. const website$8 = {
  699. regexp: new RegExp("leetcode"),
  700. init: function() {
  701. utils.hideButton();
  702. utils.enableOnCopy("#lc-home");
  703. }
  704. };
  705.  
  706. const website$7 = {
  707. regexp: /csdn/,
  708. init: function() {
  709. utils.hideButton();
  710. utils.enableOnCopyByCapture();
  711. utils.enableUserSelectByCSS();
  712. }
  713. };
  714.  
  715. const website$6 = {
  716. regexp: new RegExp("bilibili"),
  717. init: function() {
  718. utils.hideButton();
  719. utils.enableOnCopyByCapture();
  720. }
  721. };
  722.  
  723. const website$5 = {
  724. regexp: new RegExp("cnki"),
  725. init: function() {
  726. utils.hideButton();
  727. utils.enableOnContextMenuByCapture();
  728. utils.enableOnKeyDownByCapture();
  729. utils.enableOnCopyByCapture();
  730. }
  731. };
  732.  
  733. const website$4 = {
  734. regexp: new RegExp("docin.com/.*"),
  735. config: {
  736. initCopyEvent: false,
  737. captureInstance: true,
  738. delay: 100
  739. },
  740. init: function() {
  741. window.addEventListener(PAGE_LOADED, () => {
  742. var _a;
  743. return (_a = dom$1.query("#j_select")) == null ? void 0 : _a.click();
  744. });
  745. dom$1.append("head", "<style>#reader-copy-el{display: none;}</style>");
  746. },
  747. getSelectedText: function() {
  748. if (unsafeWindow.docinReader && unsafeWindow.docinReader.st) {
  749. return unsafeWindow.docinReader.st;
  750. }
  751. return "";
  752. }
  753. };
  754.  
  755. const website$3 = {
  756. regexp: /note\.youdao\.com\/newEditorV1\/bulb\.html.*/,
  757. init: function() {
  758. utils.hideButton();
  759. utils.enableUserSelectByCSS();
  760. document.addEventListener(MOUSE_DOWN, stopNativePropagation, true);
  761. document.addEventListener(MOUSE_MOVE, stopNativePropagation, true);
  762. }
  763. };
  764.  
  765. const website$2 = {
  766. regexp: new RegExp(
  767. [
  768. "commandlinux",
  769. "cnki",
  770. "ruiwen",
  771. "oh100",
  772. "fwsir",
  773. "wenxm",
  774. "unjs",
  775. "ahsrst",
  776. "yjbys",
  777. "360doc",
  778. "850500",
  779. "jianbiaoku",
  780. "kt250",
  781. "kejudati",
  782. "baibeike",
  783. "yuque",
  784. "cnrencai",
  785. "kodiplayer",
  786. "tongxiehui",
  787. "ndPureView",
  788. "jianshu",
  789. "linovelib",
  790. "chazidian",
  791. "juejin",
  792. "zgbk",
  793. "wenmi",
  794. "yuedu\\.baidu",
  795. "inrrp",
  796. "shubaoc",
  797. "51cto",
  798. "ximalaya",
  799. "xiexiebang",
  800. "ddwk8",
  801. "php\\.cn",
  802. "fanqienovel\\.com/reader",
  803. "cooco\\.net\\.cn",
  804. "mobiletrain",
  805. "xiangqiqipu"
  806. ].join("|")
  807. ),
  808. init: function() {
  809. utils.hideButton();
  810. utils.enableUserSelectByCSS();
  811. utils.enableOnCopyByCapture();
  812. }
  813. };
  814.  
  815. const website$1 = {
  816. regexp: new RegExp(["wjx", "fanyi\\.baidu", "tianqi", "rrdynb", "fuwu7"].join("|")),
  817. init: function() {
  818. utils.hideButton();
  819. utils.enableUserSelectByCSS();
  820. utils.enableOnCopyByCapture();
  821. utils.enableOnKeyDownByCapture();
  822. utils.enableOnSelectStartByCapture();
  823. utils.enableOnContextMenuByCapture();
  824. }
  825. };
  826.  
  827. const website = {
  828. config: {
  829. runAt: DOM_STAGE.START
  830. },
  831. regexp: new RegExp(["examcoo"].join("|")),
  832. init: function() {
  833. utils.hideButton();
  834. utils.enableUserSelectByCSS();
  835. utils.enableOnCopyByCapture();
  836. utils.enableOnKeyDownByCapture();
  837. utils.enableOnSelectStartByCapture();
  838. utils.enableOnContextMenuByCapture();
  839. }
  840. };
  841.  
  842. const websites = [
  843. website$s,
  844. website$r,
  845. website$q,
  846. website$p,
  847. website$o,
  848. website$n,
  849. website$m,
  850. website$l,
  851. website$k,
  852. website$j,
  853. website$i,
  854. website$h,
  855. website$g,
  856. website$f,
  857. website$e,
  858. website$d,
  859. website$c,
  860. website$b,
  861. website$a,
  862. website$9,
  863. website$t,
  864. website$8,
  865. website$7,
  866. website$6,
  867. website$5,
  868. website$4,
  869. website$3,
  870. website$2,
  871. website$1,
  872. website
  873. ];
  874.  
  875. let siteGetSelectedText = null;
  876. const initWebsite = () => {
  877. let websiteConfig = {
  878. initCopyEvent: true,
  879. runAt: DOM_STAGE.END,
  880. captureInstance: false,
  881. delay: 0
  882. };
  883. const mather = (regex, website) => {
  884. if (regex.test(window.location.href)) {
  885. if (website.config)
  886. websiteConfig = Object.assign(websiteConfig, website.config);
  887. if (websiteConfig.runAt === DOM_STAGE.END) {
  888. window.addEventListener(DOM_READY, () => website.init());
  889. } else {
  890. website.init();
  891. }
  892. if (website.getSelectedText)
  893. siteGetSelectedText = website.getSelectedText;
  894. return true;
  895. }
  896. return false;
  897. };
  898. websites.some((website) => mather(website.regexp, website));
  899. return websiteConfig;
  900. };
  901. const getSelectedText = () => {
  902. if (siteGetSelectedText)
  903. return siteGetSelectedText();
  904. if (window.getSelection)
  905. return window.getSelection().toString();
  906. if (document.getSelection)
  907. return document.getSelection().toString();
  908. if (document.selection)
  909. return document.selection.createRange().text;
  910. return "";
  911. };
  912.  
  913. (function() {
  914. const websiteConfig = initWebsite();
  915. initBaseEvent(websiteConfig);
  916. initBaseStyle();
  917. window.addEventListener(
  918. MOUSE_UP,
  919. (e) => {
  920. const handler = () => {
  921. const content = getSelectedText();
  922. if (isEmptyContent(content)) {
  923. instance.hide();
  924. return "";
  925. }
  926. instance.onCopy(content, e);
  927. };
  928. websiteConfig.delay ? setTimeout(handler, websiteConfig.delay) : handler();
  929. },
  930. websiteConfig.captureInstance
  931. );
  932. })();
  933.  
  934. })();

QingJ © 2025

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