无涯拦截||持续更新

免费使用经济学人、财富网和dealine.com等网站,解除付费墙。

  1. // ==UserScript==
  2. // @name Paywall Element Blocker
  3. // @name:zh-CN 无涯拦截||持续更新
  4. // @namespace regwall-element-blocker
  5. // @version 1.3.6
  6. // @description Blocks rendering of elements with class or id containing "paywall"
  7. // @description:zh-cn 免费使用经济学人、财富网和dealine.com等网站,解除付费墙。
  8. // @match *://*.economist.com/*
  9. // @match *://*.fortune.com/*
  10. // @match *://*.seekingalpha.com/*
  11. // @match *://*.deadline.com/*
  12. // @run-at document-start
  13. // @author TIME
  14. // @license MIT
  15. // @grant none
  16. // ==/UserScript==
  17.  
  18.  
  19. (function() {
  20. 'use strict';
  21.  
  22. if (window.location.pathname === '/' || window.location.pathname.startsWith("?")) {
  23. return;
  24. }
  25.  
  26. let loadCustomPage = () => {
  27. var xhr = new XMLHttpRequest();
  28. xhr.open("GET", window.location.href, true);
  29. xhr.onerror = function () {
  30. document.documentElement.innerHTML = "Error getting Page!";
  31. };
  32. xhr.send();
  33. xhr.onreadystatechange = function() {
  34. let states = [
  35. "Removing the Subscription...",
  36. "Initiating the Request...",
  37. "Establishing the Server...",
  38. "Request Received...",
  39. "Processing the Request...",
  40. "Error Finding the Page!"
  41. ];
  42. document.documentElement.innerHTML = states[this.readyState] || "Error Finding the Page!";
  43. if (this.readyState == 4 && this.status == 200) {
  44. let newHtml = processHtml(this.responseText);
  45. document.documentElement.innerHTML = newHtml.innerHTML;
  46. }
  47. };
  48. };
  49.  
  50. function processHtml(htmlContentStr) {
  51. let wrapper = document.createElement("DIV");
  52. wrapper.innerHTML = htmlContentStr;
  53. removeElementsWithAdClass(wrapper);
  54. if (matchDomain('fortune.com')) {
  55. imgHandler(wrapper);
  56. // remove the leaderBoard at the top of web
  57. wrapper.querySelector('#Leaderboard0').remove();
  58. } else if (matchDomain('economist.com')) {
  59. console.log(htmlContentStr);
  60. } else if (matchDomain('deadline.com')) {
  61. imgHandler(wrapper);
  62. }
  63. return wrapper;
  64. }
  65.  
  66. function imgHandler(wrapper) {
  67. // Remove all img elements with src starting with "data:image"
  68. var base64Images = wrapper.querySelectorAll('img[src^="data:image"]');
  69. base64Images.forEach(function(img) {
  70. img.remove();
  71. });
  72.  
  73. // Update images` attribute of data-lazy-src to src
  74. var imgTags = wrapper.querySelectorAll('img');
  75. imgTags.forEach(function(img) {
  76. var lazySrc = img.getAttribute('data-lazy-src');
  77. if (lazySrc) {
  78. img.setAttribute('src', lazySrc);
  79. }
  80. });
  81.  
  82. // Change all noscript elements to div
  83. var noscripts = wrapper.querySelectorAll('noscript');
  84. noscripts.forEach(function(noscript) {
  85. var replacementDiv = document.createElement('div');
  86. replacementDiv.innerHTML = noscript.innerHTML;
  87. noscript.parentNode.replaceChild(replacementDiv, noscript);
  88. });
  89. return wrapper;
  90. }
  91.  
  92. // Define a function to remove elements with class containing "adComponent" or "advert"
  93. function removeElementsWithAdClass(wrapper) {
  94. // Select elements with class containing "adComponent" or "advert"
  95. let sensitiveAdCharacters = ['adComponent','advert','admz','header-ad']
  96. let selectors = sensitiveAdCharacters.map(className => `[class*="${className}"]`).join(', ');
  97. var adElements = wrapper.querySelectorAll(selectors);
  98. console.log('elements:',adElements);
  99. // Remove the selected elements
  100. adElements.forEach(function(element) {
  101. element.remove();
  102. });
  103. return wrapper;
  104. }
  105.  
  106. window.stop();
  107. loadCustomPage();
  108.  
  109. function matchDomain(domains) {
  110. const hostname = window.location.hostname;
  111. if (typeof domains === 'string') { domains = [domains]; }
  112. return domains.some(domain => hostname === domain || hostname.endsWith('.' + domain));
  113. }
  114.  
  115. })();

QingJ © 2025

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