Removes all ads and provides clean PDF download for Panacea Concept articles
Size
7.3 KB
Version
1.1.1
Created
Nov 18, 2025
Updated
25 days ago
1// ==UserScript==
2// @name Panacea Concept Ad-Free PDF Downloader
3// @description Removes all ads and provides clean PDF download for Panacea Concept articles
4// @version 1.1.1
5// @match https://*.panaceaconcept.in/*
6// @require https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js
7// ==/UserScript==
8(function() {
9 'use strict';
10
11 console.log('Panacea Concept Ad-Free PDF Downloader - Starting');
12
13 // Add custom styles
14 const style = document.createElement('style');
15 style.textContent = `
16 /* Hide all ad-related elements */
17 .adsbygoogle,
18 .google-auto-placed,
19 .ap_container,
20 ins.adsbygoogle,
21 .fc-message-root,
22 .fc-monetization-dialog-container,
23 .fc-dialog-overlay,
24 iframe[id*="aswift"],
25 iframe[title*="Advertisement"] {
26 display: none !important;
27 visibility: hidden !important;
28 opacity: 0 !important;
29 height: 0 !important;
30 width: 0 !important;
31 }
32
33 /* PDF Download Button Styles */
34 #pdf-download-btn {
35 position: fixed;
36 top: 100px;
37 right: 20px;
38 z-index: 9999;
39 background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
40 color: white;
41 border: none;
42 padding: 15px 25px;
43 font-size: 16px;
44 font-weight: bold;
45 border-radius: 50px;
46 cursor: pointer;
47 box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
48 transition: all 0.3s ease;
49 font-family: Arial, sans-serif;
50 }
51
52 #pdf-download-btn:hover {
53 transform: translateY(-2px);
54 box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
55 background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
56 }
57
58 #pdf-download-btn:active {
59 transform: translateY(0);
60 }
61
62 #pdf-download-btn.downloading {
63 background: #95a5a6;
64 cursor: wait;
65 }
66
67 /* Clean up the content area for PDF */
68 .entry-content {
69 background: white;
70 padding: 20px;
71 }
72 `;
73 document.head.appendChild(style);
74 console.log('Styles added');
75
76 // Generate and download PDF
77 async function generatePDF() {
78 const button = document.getElementById('pdf-download-btn');
79 button.classList.add('downloading');
80 button.innerHTML = '⏳ Generating PDF...';
81 console.log('Generating PDF...');
82
83 try {
84 const contentElement = document.querySelector('.entry-content');
85
86 if (!contentElement) {
87 alert('Could not find content to convert to PDF');
88 return;
89 }
90
91 const clonedContent = contentElement.cloneNode(true);
92 const adsInClone = clonedContent.querySelectorAll('.adsbygoogle, .google-auto-placed, .ap_container, ins.adsbygoogle');
93 adsInClone.forEach(ad => ad.remove());
94
95 const pageTitle = document.querySelector('.entry-title')?.textContent || 'document';
96 const filename = pageTitle.replace(/[^a-z0-9]/gi, '_').toLowerCase() + '.pdf';
97
98 const opt = {
99 margin: [15, 15, 15, 15],
100 filename: filename,
101 image: { type: 'jpeg', quality: 0.98 },
102 html2canvas: {
103 scale: 2,
104 useCORS: true,
105 logging: false,
106 letterRendering: true,
107 windowWidth: contentElement.scrollWidth,
108 windowHeight: contentElement.scrollHeight
109 },
110 jsPDF: {
111 unit: 'mm',
112 format: 'a4',
113 orientation: 'portrait',
114 compress: true
115 },
116 pagebreak: {
117 mode: ['avoid-all', 'css', 'legacy'],
118 before: '.page-break-before',
119 after: '.page-break-after',
120 avoid: ['tr', 'td', 'th', 'img']
121 }
122 };
123
124 await html2pdf().set(opt).from(clonedContent).save();
125
126 console.log('PDF generated successfully');
127 button.innerHTML = '✅ PDF Downloaded!';
128
129 setTimeout(() => {
130 button.classList.remove('downloading');
131 button.innerHTML = '📄 Download PDF';
132 }, 3000);
133
134 } catch (error) {
135 console.error('Error generating PDF:', error);
136 alert('Error generating PDF. Please try again.');
137 button.classList.remove('downloading');
138 button.innerHTML = '📄 Download PDF';
139 }
140 }
141
142 // Function to remove all ads and unwanted elements
143 function removeAds() {
144 console.log('Removing ads...');
145
146 // Remove Google AdSense ads
147 const adsenseElements = document.querySelectorAll('.adsbygoogle, ins.adsbygoogle, .google-auto-placed, .ap_container');
148 adsenseElements.forEach(ad => ad.remove());
149
150 // Remove ad iframes
151 const adIframes = document.querySelectorAll('iframe[id*="aswift"], iframe[title*="Advertisement"], iframe[aria-label*="Advertisement"]');
152 adIframes.forEach(iframe => iframe.remove());
153
154 // Remove floating dialog/popup ads
155 const floatingAds = document.querySelectorAll('.fc-message-root, .fc-monetization-dialog-container, .fc-dialog-overlay, .fc-dialog');
156 floatingAds.forEach(ad => ad.remove());
157
158 // Remove any ad scripts
159 const adScripts = document.querySelectorAll('script[src*="adsbygoogle"], script[src*="googlesyndication"]');
160 adScripts.forEach(script => script.remove());
161
162 // Remove common ad containers (but not our PDF button)
163 const adContainers = document.querySelectorAll('[class*="ad-container"], [class*="advertisement"], [id*="ad-"], [class*="banner"]');
164 adContainers.forEach(container => {
165 // Skip our PDF button
166 if (container.id === 'pdf-download-btn') {
167 return;
168 }
169 if (container.offsetHeight > 0 || container.offsetWidth > 0) {
170 container.remove();
171 }
172 });
173
174 // Create PDF button if it doesn't exist
175 if (!document.getElementById('pdf-download-btn')) {
176 console.log('Creating PDF button inside removeAds...');
177 const pdfButton = document.createElement('button');
178 pdfButton.id = 'pdf-download-btn';
179 pdfButton.innerHTML = '📄 Download PDF';
180 pdfButton.addEventListener('click', generatePDF);
181 document.body.appendChild(pdfButton);
182 console.log('PDF button created!');
183 }
184
185 console.log('Ads removed');
186 }
187
188 // Remove ads immediately
189 removeAds();
190
191 // Observe DOM changes to remove dynamically loaded ads
192 const observer = new MutationObserver(() => {
193 const ads = document.querySelectorAll('.adsbygoogle, .google-auto-placed, .fc-message-root');
194 if (ads.length > 0) {
195 removeAds();
196 }
197 });
198
199 observer.observe(document.body, {
200 childList: true,
201 subtree: true
202 });
203
204 // Remove ads periodically
205 setTimeout(removeAds, 1000);
206 setTimeout(removeAds, 3000);
207 setTimeout(removeAds, 5000);
208
209 console.log('Extension initialized');
210
211})();