Removes paywalls, subscription popups, and advertisements from The Hindu website
Size
8.5 KB
Version
1.1.1
Created
Oct 29, 2025
Updated
about 1 month ago
1// ==UserScript==
2// @name The Hindu Paywall Bypasser & Ad Remover
3// @description Removes paywalls, subscription popups, and advertisements from The Hindu website
4// @version 1.1.1
5// @match https://*.thehindu.com/*
6// @icon https://www.thehindu.com/favicon.ico
7// ==/UserScript==
8(function() {
9 'use strict';
10
11 console.log('The Hindu Paywall Bypasser & Ad Remover initialized');
12
13 // Function to remove paywall and subscription elements
14 function removePaywallElements() {
15 const paywallSelectors = [
16 '#subscriptioncontainer',
17 '.subscriptioncontainer',
18 '.paywall',
19 '.paywall-container',
20 '.subscription-banner',
21 '.prime-article-banner',
22 '[class*="paywall"]',
23 '[class*="subscription"]',
24 '[id*="paywall"]',
25 '[id*="subscription"]',
26 '.modal-backdrop',
27 '.modal[style*="display: block"]',
28 'div[class*="overlay"]',
29 'div[class*="popup"]',
30 // New aggressive selectors
31 'a[href*="subscription"]',
32 '.btn-subscribe',
33 'button[class*="subscribe"]',
34 '[data-test*="subscribe"]',
35 '[aria-label*="subscribe" i]',
36 '[aria-label*="subscription" i]',
37 'div[class*="subscribe"]',
38 'section[class*="subscribe"]',
39 '[id*="subscribe"]'
40 ];
41
42 paywallSelectors.forEach(selector => {
43 const elements = document.querySelectorAll(selector);
44 elements.forEach(el => {
45 console.log('Removing paywall element:', el);
46 el.remove();
47 });
48 });
49 }
50
51 // Function to remove login and account buttons
52 function removeLoginElements() {
53 const loginSelectors = [
54 'a[href*="myaccount"]',
55 '.btn-account',
56 'button[class*="account"]',
57 '[data-test*="login"]',
58 '[data-test*="signin"]',
59 '[aria-label*="login" i]',
60 '[aria-label*="sign in" i]',
61 'a[href*="login"]',
62 'a[href*="signin"]',
63 'button[class*="login"]',
64 'button[class*="signin"]'
65 ];
66
67 loginSelectors.forEach(selector => {
68 const elements = document.querySelectorAll(selector);
69 elements.forEach(el => {
70 console.log('Removing login element:', el);
71 el.remove();
72 });
73 });
74 }
75
76 // Function to remove ads
77 function removeAds() {
78 const adSelectors = [
79 'iframe[src*="ads"]',
80 'iframe[src*="doubleclick"]',
81 'iframe[src*="googlesyndication"]',
82 'div[id*="ad"]',
83 'div[class*="ad-"]',
84 'div[class*="advertisement"]',
85 'div[class*="advert"]',
86 '[class*="google-ad"]',
87 '[id*="google_ads"]',
88 '.ad-container',
89 '.ad-wrapper',
90 '.ad-slot',
91 '.banner-ad',
92 'ins.adsbygoogle',
93 '[data-ad-slot]',
94 '[data-google-query-id]'
95 ];
96
97 adSelectors.forEach(selector => {
98 const elements = document.querySelectorAll(selector);
99 elements.forEach(el => {
100 console.log('Removing ad element:', el);
101 el.remove();
102 });
103 });
104 }
105
106 // Function to unlock article content
107 function unlockContent() {
108 // Remove blur effects
109 const blurredElements = document.querySelectorAll('[style*="blur"]');
110 blurredElements.forEach(el => {
111 el.style.filter = 'none';
112 el.style.webkitFilter = 'none';
113 });
114
115 // Remove height restrictions
116 const restrictedElements = document.querySelectorAll('[style*="max-height"], [style*="overflow: hidden"]');
117 restrictedElements.forEach(el => {
118 el.style.maxHeight = 'none';
119 el.style.overflow = 'visible';
120 });
121
122 // Enable scrolling - force it with setProperty!
123 document.body.style.setProperty('overflow', 'auto', 'important');
124 document.documentElement.style.setProperty('overflow', 'auto', 'important');
125 document.body.style.setProperty('position', 'static', 'important');
126 document.documentElement.style.setProperty('position', 'static', 'important');
127 document.body.style.setProperty('height', 'auto', 'important');
128 document.documentElement.style.setProperty('height', 'auto', 'important');
129
130 // Remove pointer-events blocking
131 const blockedElements = document.querySelectorAll('[style*="pointer-events"]');
132 blockedElements.forEach(el => {
133 el.style.pointerEvents = 'auto';
134 });
135
136 // Unlock premium content
137 const premiumElements = document.querySelectorAll('[class*="premium"], [class*="locked"], [data-premium]');
138 premiumElements.forEach(el => {
139 el.classList.remove('premium', 'locked', 'premium-content');
140 el.removeAttribute('data-premium');
141 el.style.filter = 'none';
142 el.style.pointerEvents = 'auto';
143 });
144 }
145
146 // Add CSS to hide common paywall and ad patterns
147 const style = document.createElement('style');
148 style.textContent = `
149 /* Hide paywall elements */
150 #subscriptioncontainer,
151 .subscriptioncontainer,
152 .paywall,
153 .paywall-container,
154 .subscription-banner,
155 .prime-article-banner,
156 [class*="paywall"],
157 [id*="paywall"],
158 .modal-backdrop,
159 a[href*="subscription"],
160 .btn-subscribe,
161 button[class*="subscribe"],
162 div[class*="subscribe"],
163 section[class*="subscribe"],
164 [id*="subscribe"],
165 a[href*="myaccount"],
166 .btn-account {
167 display: none !important;
168 visibility: hidden !important;
169 opacity: 0 !important;
170 height: 0 !important;
171 width: 0 !important;
172 position: absolute !important;
173 left: -9999px !important;
174 }
175
176 /* Hide ads */
177 iframe[src*="ads"],
178 iframe[src*="doubleclick"],
179 iframe[src*="googlesyndication"],
180 div[id*="ad-"],
181 div[class*="ad-"],
182 div[class*="advertisement"],
183 .ad-container,
184 .ad-wrapper,
185 .ad-slot,
186 .banner-ad,
187 ins.adsbygoogle,
188 [data-ad-slot],
189 [data-google-query-id] {
190 display: none !important;
191 visibility: hidden !important;
192 }
193
194 /* Ensure content is visible and scrollable */
195 body, html {
196 overflow: auto !important;
197 position: static !important;
198 height: auto !important;
199 }
200
201 /* Remove blur effects */
202 .article-content,
203 .articlebodycontent,
204 [class*="article"] {
205 filter: none !important;
206 -webkit-filter: none !important;
207 max-height: none !important;
208 overflow: visible !important;
209 }
210
211 /* Unlock premium content */
212 [class*="premium"],
213 [class*="locked"],
214 [data-premium] {
215 filter: none !important;
216 pointer-events: auto !important;
217 opacity: 1 !important;
218 }
219 `;
220 document.head.appendChild(style);
221
222 // Debounce function to prevent excessive calls
223 function debounce(func, wait) {
224 let timeout;
225 return function executedFunction(...args) {
226 const later = () => {
227 clearTimeout(timeout);
228 func(...args);
229 };
230 clearTimeout(timeout);
231 timeout = setTimeout(later, wait);
232 };
233 }
234
235 // Main cleanup function
236 function cleanPage() {
237 removePaywallElements();
238 removeLoginElements();
239 removeAds();
240 unlockContent();
241 }
242
243 // Run cleanup immediately
244 cleanPage();
245
246 // Run cleanup after DOM is fully loaded
247 if (document.readyState === 'loading') {
248 document.addEventListener('DOMContentLoaded', cleanPage);
249 }
250
251 // Run cleanup after page is fully loaded
252 window.addEventListener('load', cleanPage);
253
254 // Watch for dynamic content changes
255 const debouncedCleanPage = debounce(cleanPage, 1000);
256 const observer = new MutationObserver(debouncedCleanPage);
257
258 observer.observe(document.body, {
259 childList: true,
260 subtree: true
261 });
262
263 // Periodic cleanup every 2 seconds for persistent elements
264 setInterval(cleanPage, 2000);
265
266 console.log('The Hindu Paywall Bypasser & Ad Remover is active');
267})();