FuckNoCopy

移除页面的复制限制,取消所有复制后添加的版权申明,理论上支持所有网站,包含知乎,CSDN等页面。本脚本仅解除了技术上的复制限制,请在合理的范围内使用,尊重内容版权,不要未经授权使用或传播他人作品。

  1. // ==UserScript==
  2. // @name FuckNoCopy
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description 移除页面的复制限制,取消所有复制后添加的版权申明,理论上支持所有网站,包含知乎,CSDN等页面。本脚本仅解除了技术上的复制限制,请在合理的范围内使用,尊重内容版权,不要未经授权使用或传播他人作品。
  6. // @author zheng-kun@foxmail.com
  7. // @match *://*/*
  8. // @grant GM_addStyle
  9. // @grant GM_setClipboard
  10. // @license MIT
  11. // @require https://libs.baidu.com/jquery/1.9.1/jquery.min.js
  12. // @exclude *://localhost:*/*
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. // 不展示登录框
  18. GM_addStyle(".passport-login-container{display:none!important;}");
  19. // 解除代码块的选中限制
  20. GM_addStyle("#content_views pre code {user-select: text!important;}");
  21.  
  22.  
  23. // 创建一个 MutationObserver 实例
  24. const observer = new MutationObserver(() => {
  25. // 检测并移除所有 copy 事件监听器
  26. document.querySelectorAll('*').forEach(element => {
  27. const eventListeners = element['eventListeners'];
  28. if (eventListeners && eventListeners.copy) {
  29. eventListeners.copy.forEach(listener => {
  30. element.removeEventListener('copy', listener.listener);
  31. });
  32. }
  33. });
  34. });
  35.  
  36. // 开始监听 document 的 DOM 变化
  37. observer.observe(document, { childList: true, subtree: true });
  38.  
  39. // 重新绑定自定义的 copy 事件监听器
  40. document.addEventListener('copy', function(event) {
  41. event.preventDefault(); // 阻止默认行为
  42. const selection = window.getSelection().toString();
  43. if (selection) {
  44. event.clipboardData.setData('text/plain', selection);
  45. }
  46. }, { capture: true }); // 使用捕获阶段,确保优先执行
  47.  
  48.  
  49.  
  50. function replaceAllCopy() {
  51. document.querySelectorAll('*').forEach(item => {
  52. item.oncopy = function(e) {
  53. e.stopPropagation();
  54. e.preventDefault(); // 阻止默认行为
  55. };
  56. });
  57. }
  58.  
  59. // 在文档加载完成后移除一次
  60. document.addEventListener('DOMContentLoaded', function() {
  61. replaceAllCopy()
  62. });
  63.  
  64. // 每隔 5 秒移除一次
  65. setInterval(replaceAllCopy, 5000);
  66. })();