Greasy Fork

Greasy Fork is available in English.

解除复制限制

解除部分网站的复制限制及小尾巴,如百度文库、CSDN、哔哩哔哩专栏等。

当前为 2024-03-11 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         解除复制限制
// @namespace    https://github.com/LU-JIEJIE/copyable
// @version      1.1.1
// @author       lu-jiejie
// @description  解除部分网站的复制限制及小尾巴,如百度文库、CSDN、哔哩哔哩专栏等。
// @license      MIT
// @homepage     https://github.com/LU-JIEJIE/copyable
// @match        *://www.bilibili.com/read/*
// @match        *://blog.csdn.net/*
// @match        *://wenku.csdn.net/*
// @match        *://www.examcoo.com/editor/do/*
// @match        *://wenku.baidu.com/view/*
// @match        *://*.feishu.cn/*
// @match        *://docs.qq.com/doc/*
// @grant        unsafeWindow
// ==/UserScript==

(function () {
  'use strict';

  const BaiduWenku = {
    regexp: /wenku.baidu.com\/view/,
    handler: () => {
      document.querySelector(".header-wrapper").__vue__.$store.state.vipInfo.isVip = true;
      document.addEventListener("copy", async () => {
        const originClipboard = await navigator.clipboard.readText();
        const tailPattern = /(-{56,})[\s\S]*?作者:/;
        const match = tailPattern.exec(originClipboard);
        let newClipboard = originClipboard;
        if (match)
          newClipboard = originClipboard.substring(0, match.index).trim();
        navigator.clipboard.writeText(newClipboard);
      });
      document.addEventListener("keydown", (e) => {
        var _a;
        if (!(e.ctrlKey && e.key === "c") || ((_a = window.getSelection()) == null ? void 0 : _a.toString()) || document.querySelector("canvas") && !document.querySelector("#original-creader-interative-canvas-1"))
          return;
        document.querySelector(".reader-copy-button").click();
      });
    }
  };
  const stopCopyPropagation = () => {
    document.addEventListener("copy", (e) => {
      e.stopPropagation();
    }, true);
  };
  const stopSelectStartPropagation = () => {
    document.addEventListener("selectstart", (e) => {
      e.stopPropagation();
    }, true);
  };
  const enableCssUserSelect = () => {
    const css = "* {user-select: auto !important; -webkit-user-select: auto !important; cursor: auto !important;}";
    const style = document.createElement("style");
    style.textContent = css;
    document.head.appendChild(style);
  };
  const BilibiliRead = {
    regexp: /www.bilibili.com\/read/,
    handler: () => {
      stopCopyPropagation();
    }
  };
  const CSDN = {
    regexp: /csdn/,
    handler: () => {
      stopCopyPropagation();
      enableCssUserSelect();
    }
  };
  const Examcoo = {
    regexp: /examcoo/,
    handler: () => {
      stopSelectStartPropagation();
      enableCssUserSelect();
    }
  };
  const Feishu = {
    regexp: /feishu.cn/,
    handler: () => {
      stopCopyPropagation();
    }
  };
  var _unsafeWindow = /* @__PURE__ */ (() => typeof unsafeWindow != "undefined" ? unsafeWindow : void 0)();
  const QQDoc = {
    regexp: /docs.qq.com\/doc/,
    handler: () => {
      document.addEventListener("keydown", (e) => {
        if (!(e.ctrlKey && e.key === "c"))
          return;
        e.preventDefault();
        const selectText = _unsafeWindow.pad.editor.getCopyContent().plain;
        navigator.clipboard.writeText(selectText);
      });
    }
  };
  const websites = [
    BaiduWenku,
    BilibiliRead,
    CSDN,
    Examcoo,
    Feishu,
    QQDoc
  ];
  websites.some((website) => {
    if (website.regexp.test(window.location.href)) {
      website.handler();
      return true;
    }
    return false;
  });

})();