Adblock Protector

Advanced Adblock protector with invasive shit blocking

  1. // ==UserScript==
  2. // @name Adblock Protector
  3. // @name:uk Захисник Adblock
  4. // @name:de Adblock Protector
  5. // @name:fr Adblock Protector
  6. // @name:es Adblock Protector
  7. // @name:et Adblock Protector
  8. // @name:it Adblock Protector
  9. // @version 1.3
  10. // @description Advanced Adblock protector with invasive shit blocking
  11. // @description:uk Adblock Protector. Захищає від стеження та обходу блокувальників реклами
  12. // @description:de Fortschrittlicher Adblock-Schutz mit invasivem Scheiß-Blockieren
  13. // @description:fr Protecteur Adblock avancé avec blocage de merde invasive
  14. // @description:es Protector Adblock avanzado con bloqueo de mierda invasiva
  15. // @description:et Täiustatud Adblocki kaitse invasivse jama blokeerimisega
  16. // @description:it Protettore Adblock avanzato con blocco di merda invasiva
  17. // @match *://*/*
  18. // @grant none
  19. // @run-at document-start
  20. // @noframes
  21. // @namespace https://gf.qytechs.cn/users/1451793
  22. // ==/UserScript==
  23.  
  24. /* Configuration Object */
  25. var config = {
  26. blockingLevel: 2, // 1-3 (1=yandex, 2=+RU companies, 3=nuclear)
  27. aggressiveness: 2, // 1-3 (1=reqs, 2=+scripts, 3=all elements)
  28. advancedProtection: 1, // 0-1 (external scripts)
  29. proactiveDefense: true, // Active bypass prevention
  30. sanitizeInterval: 2000 // DOM cleanup interval
  31. };
  32.  
  33. /* Domain Patterns */
  34. var domainPatterns = {
  35. yandex: ['ya.*', 'yandex.*', 'yastatic.*'],
  36. ruCompanies: ['mail.ru', 'zen.ru', 'vk.ru', 'vk.com', 'ok.ru'],
  37. nuclear: ['*.ru', '*.by', '*.рф', '*.su']
  38. };
  39.  
  40. (function() {
  41. 'use strict';
  42.  
  43. // Build blocked domains array
  44. var blockedDomains = domainPatterns.yandex.slice();
  45. if (config.blockingLevel >= 2) blockedDomains.push.apply(blockedDomains, domainPatterns.ruCompanies);
  46. if (config.blockingLevel >= 3) blockedDomains.push.apply(blockedDomains, domainPatterns.nuclear);
  47.  
  48. // Create regex patterns
  49. var domainRegexes = blockedDomains.map(function(pattern) {
  50. var base = pattern
  51. .replace(/\./g, '\\.')
  52. .replace(/\*/g, '.*');
  53. return [
  54. new RegExp('^(https?|wss?)://([a-z0-9-]+\\.)*' + base),
  55. new RegExp('//([a-z0-9-]+\\.)*' + base),
  56. new RegExp('([a-z0-9-]+\\.)*' + base + '/', 'i')
  57. ];
  58. }).reduce(function(acc, val) { return acc.concat(val); }, []);
  59.  
  60. // Block check function
  61. function isBlocked(url) {
  62. try {
  63. var cleanUrl = decodeURIComponent(url).toLowerCase();
  64. return domainRegexes.some(function(regex) {
  65. return regex.test(cleanUrl);
  66. });
  67. } catch(e) {
  68. return domainRegexes.some(function(regex) {
  69. return regex.test(url.toLowerCase());
  70. });
  71. }
  72. }
  73.  
  74. // Network blocking
  75. var nativeFetch = window.fetch;
  76. window.fetch = function(input, init) {
  77. var url = (typeof input === 'string') ? input : input.url;
  78. return isBlocked(url)
  79. ? new Response(null, { status: 403 })
  80. : nativeFetch.call(window, input, init);
  81. };
  82.  
  83. var originalOpen = XMLHttpRequest.prototype.open;
  84. XMLHttpRequest.prototype.open = function(method, url) {
  85. if (isBlocked(url)) {
  86. console.warn('Blocked XHR:', url);
  87. this.abort();
  88. return;
  89. }
  90. originalOpen.apply(this, arguments);
  91. };
  92.  
  93. // DOM cleaning
  94. function sanitizeDOM() {
  95. var elements = document.querySelectorAll(
  96. 'script, iframe, img, link, embed, object, source'
  97. );
  98. Array.prototype.forEach.call(elements, function(element) {
  99. var sources = [
  100. element.src,
  101. element.href,
  102. element.dataset && element.dataset.src,
  103. element.srcset
  104. ].filter(Boolean);
  105.  
  106. if (sources.some(isBlocked)) {
  107. if (element.parentNode) {
  108. element.parentNode.removeChild(element);
  109. }
  110. }
  111. });
  112. }
  113.  
  114. // Mutation observer
  115. var observer = new MutationObserver(function(mutations) {
  116. mutations.forEach(function(mutation) {
  117. Array.prototype.forEach.call(mutation.addedNodes, function(node) {
  118. if (node.nodeType === 1 && (node.src || node.href)) {
  119. if (isBlocked(node.src || node.href)) {
  120. node.parentNode && node.parentNode.removeChild(node);
  121. }
  122. }
  123. });
  124. });
  125. if (config.aggressiveness >= 2) sanitizeDOM();
  126. });
  127.  
  128. observer.observe(document, {
  129. childList: true,
  130. subtree: true,
  131. attributes: true,
  132. attributeFilter: ['src', 'href', 'data-src']
  133. });
  134.  
  135. // External scripts
  136. if (config.advancedProtection) {
  137. [
  138. 'https://userscripts.adtidy.org/release/popup-blocker/2.5/popupblocker.user.js',
  139. 'https://userscripts.adtidy.org/release/adguard-extra/1.0/adguard-extra.user.js',
  140. 'https://cdn.jsdelivr.net/npm/@list-kr/tinyshield@latest/dist/tinyShield.user.js'
  141. ].forEach(function(src) {
  142. var script = document.createElement('script');
  143. script.src = src;
  144. document.head.appendChild(script);
  145. });
  146. }
  147.  
  148. // Proactive defense
  149. if (config.proactiveDefense) {
  150. setInterval(sanitizeDOM, config.sanitizeInterval);
  151. Object.defineProperty(window, 'fetch', {
  152. value: window.fetch,
  153. writable: false,
  154. configurable: false
  155. });
  156. }
  157.  
  158. console.info('Domain Blocker active - Level ' + config.blockingLevel);
  159. })();

QingJ © 2025

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