🏠 Home 

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

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


安装此脚本?
作者推荐脚本

您可能也喜欢🔥🔥🔥文本选中复制(通用)🔥🔥🔥

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