网页枷锁破除

深度破除网页内容限制 智能恢复全功能操作:右键菜单复活|文本自由选择|剪贴板无阻操作|元素拖拽解放|动态加载监控|样式强制覆盖

当前为 2025-04-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Universal Web Liberator
  3. // @name:zh-CN 网页枷锁破除
  4. // @name:zh-TW 網頁枷鎖破除
  5. // @description Deeply Unlock Web Content Limitations & Intelligently Restore Full Functionality
  6. // @description:zh-CN 深度破除网页内容限制 智能恢复全功能操作:右键菜单复活|文本自由选择|剪贴板无阻操作|元素拖拽解放|动态加载监控|样式强制覆盖
  7. // @description:zh-TW 深度破除網頁內容限制 智能恢復全功能操作:右鍵菜單復活|文本自由選擇|剪貼板無阻操作|元素拖拽解放|動態加載監控|樣式強制覆蓋
  8. // @version 1.1.1
  9. // @icon https://raw.githubusercontent.com/MiPoNianYou/UserScripts/refs/heads/main/Icons/UniversalWebLiberatorIcon.svg
  10. // @author 念柚
  11. // @namespace https://github.com/MiPoNianYou/UserScripts
  12. // @license GPL-3.0
  13. // @match *://*/*
  14. // @grant none
  15. // @run-at document-start
  16. // ==/UserScript==
  17.  
  18. class WebLiberator {
  19. constructor() {
  20. this.InitMutationObserver();
  21. this.ExecuteCoreFeatures();
  22. }
  23.  
  24. ExecuteCoreFeatures() {
  25. this.PurgeEventListeners(document.documentElement);
  26. this.InjectLiberationStyles();
  27. this.BindGlobalEvents();
  28. this.ProcessExistingNodes();
  29. }
  30.  
  31. BindGlobalEvents() {
  32. const EventHandlers = [
  33. { type: "contextmenu", handler: this.HandleContextMenu },
  34. { type: "selectstart", handler: this.HandleSelection },
  35. { type: "copy", handler: this.HandleClipboard },
  36. { type: "cut", handler: this.HandleClipboard },
  37. { type: "paste", handler: this.HandleClipboard },
  38. ];
  39.  
  40. EventHandlers.forEach(({ type, handler }) => {
  41. document.addEventListener(type, handler.bind(this), true);
  42. });
  43. }
  44.  
  45. HandleContextMenu(event) {
  46. event.stopImmediatePropagation();
  47. }
  48.  
  49. HandleSelection(event) {
  50. event.stopImmediatePropagation();
  51. }
  52.  
  53. HandleClipboard(event) {
  54. event.stopImmediatePropagation();
  55. }
  56.  
  57. InjectLiberationStyles() {
  58. const StyleSheet = new CSSStyleSheet();
  59. StyleSheet.replaceSync(`
  60. *, *::before, *::after {
  61. user-select: text !important;
  62. -webkit-user-drag: auto !important;
  63. user-drag: auto !important;
  64. }
  65. `);
  66. document.adoptedStyleSheets = [...document.adoptedStyleSheets, StyleSheet];
  67. }
  68.  
  69. ProcessExistingNodes() {
  70. this.PurgeEventListeners(document.body);
  71. requestIdleCallback(() => {
  72. const elements = document.getElementsByTagName("*");
  73. for (let i = 0; i < elements.length; i++) {
  74. this.PurgeEventListeners(elements[i]);
  75. }
  76. });
  77. }
  78.  
  79. PurgeEventListeners(element) {
  80. if (!element?.nodeType) return;
  81.  
  82. const restrictedeventprops = [
  83. "oncontextmenu",
  84. "onselectstart",
  85. "oncopy",
  86. "oncut",
  87. "onpaste",
  88. "ondrag",
  89. "ondragstart",
  90. ];
  91.  
  92. restrictedeventprops.forEach((prop) => {
  93. element[prop] = null;
  94. });
  95. }
  96.  
  97. HandleMutation(mutations) {
  98. mutations.forEach((mutation) => {
  99. if (mutation.type === "childList") {
  100. mutation.addedNodes.forEach((node) => {
  101. if (node.nodeType === Node.ELEMENT_NODE) {
  102. this.PurgeEventListeners(node);
  103. node.querySelectorAll?.("*").forEach((child) => {
  104. this.PurgeEventListeners(child);
  105. });
  106. }
  107. });
  108. }
  109. });
  110. }
  111.  
  112. InitMutationObserver() {
  113. this.observer = new MutationObserver(this.HandleMutation.bind(this));
  114. this.observer.observe(document.documentElement, {
  115. childList: true,
  116. subtree: true,
  117. attributes: false,
  118. });
  119. }
  120. }
  121.  
  122. new WebLiberator();

QingJ © 2025

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