Prepmart Premium Unlocker & PDF Exporter

Remove subscription popups, unlock premium features, remove ads, and export pages to PDF in A4 format

Size

13.0 KB

Version

1.1.1

Created

Nov 15, 2025

Updated

28 days ago

1// ==UserScript==
2// @name		Prepmart Premium Unlocker & PDF Exporter
3// @description		Remove subscription popups, unlock premium features, remove ads, and export pages to PDF in A4 format
4// @version		1.1.1
5// @match		https://*.prepmart.in/*
6// @icon		https://prepmart.in/prepmart-favicon.png?1763199057
7// @require		https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js
8// ==/UserScript==
9(function() {
10    'use strict';
11
12    console.log('Prepmart Premium Unlocker & PDF Exporter - Extension loaded');
13
14    // Utility function to debounce
15    function debounce(func, wait) {
16        let timeout;
17        return function executedFunction(...args) {
18            const later = () => {
19                clearTimeout(timeout);
20                func(...args);
21            };
22            clearTimeout(timeout);
23            timeout = setTimeout(later, wait);
24        };
25    }
26
27    // Remove subscription popup and overlays
28    function removeSubscriptionPopup() {
29        console.log('Removing subscription popups...');
30        
31        // Remove subscription modal
32        const subscriptionPopup = document.querySelector('#subscriptionPopup');
33        if (subscriptionPopup) {
34            subscriptionPopup.remove();
35            console.log('Subscription popup removed');
36        }
37
38        // Remove modal backdrops
39        const backdrops = document.querySelectorAll('.modal-backdrop');
40        backdrops.forEach(backdrop => {
41            backdrop.remove();
42            console.log('Modal backdrop removed');
43        });
44
45        // Remove any modal-open class from body
46        document.body.classList.remove('modal-open');
47        document.body.style.overflow = '';
48        document.body.style.paddingRight = '';
49    }
50
51    // Remove sign-in prompts and login modals
52    function removeSignInPrompts() {
53        console.log('Removing sign-in prompts...');
54        
55        // Common selectors for login/signin elements
56        const loginSelectors = [
57            '[id*="login"]',
58            '[id*="signin"]',
59            '[class*="login"]',
60            '[class*="signin"]',
61            '[class*="auth-modal"]',
62            '[class*="sign-in"]',
63            'div[role="dialog"][aria-labelledby*="login"]',
64            'div[role="dialog"][aria-labelledby*="signin"]'
65        ];
66
67        loginSelectors.forEach(selector => {
68            const elements = document.querySelectorAll(selector);
69            elements.forEach(el => {
70                // Check if it's a modal or popup
71                if (el.classList.contains('modal') || el.classList.contains('popup') || 
72                    el.getAttribute('role') === 'dialog') {
73                    el.remove();
74                    console.log('Sign-in element removed:', selector);
75                }
76            });
77        });
78    }
79
80    // Remove ads and banners
81    function removeAdsAndBanners() {
82        console.log('Removing ads and banners...');
83        
84        const adSelectors = [
85            '[id*="ad"]',
86            '[class*="advertisement"]',
87            '[class*="banner"]',
88            '[class*="promo"]',
89            '[class*="sponsored"]',
90            'iframe[src*="ads"]',
91            'iframe[src*="doubleclick"]',
92            'div[class*="ad-"]',
93            'aside[class*="ad"]',
94            '.google-ad',
95            '.ad-container',
96            '.banner-ad'
97        ];
98
99        adSelectors.forEach(selector => {
100            const elements = document.querySelectorAll(selector);
101            elements.forEach(el => {
102                // Only remove if it looks like an ad (not part of main content)
103                const text = el.textContent.toLowerCase();
104                if (text.includes('advertisement') || text.includes('sponsored') || 
105                    el.offsetHeight < 300 && el.querySelector('iframe')) {
106                    el.style.display = 'none';
107                    console.log('Ad/Banner hidden:', selector);
108                }
109            });
110        });
111    }
112
113    // Unlock premium features and remove question limits
114    function unlockPremiumFeatures() {
115        console.log('Unlocking premium features...');
116        
117        // Remove any blur effects on content
118        const blurredElements = document.querySelectorAll('[style*="blur"]');
119        blurredElements.forEach(el => {
120            el.style.filter = 'none';
121            el.style.webkitFilter = 'none';
122            console.log('Removed blur effect');
123        });
124
125        // Remove overlay locks
126        const overlays = document.querySelectorAll('[class*="overlay"], [class*="lock"], [class*="premium"]');
127        overlays.forEach(overlay => {
128            if (overlay.style.position === 'absolute' || overlay.style.position === 'fixed') {
129                overlay.remove();
130                console.log('Removed premium overlay');
131            }
132        });
133
134        // Enable disabled elements
135        const disabledElements = document.querySelectorAll('[disabled], [class*="disabled"]');
136        disabledElements.forEach(el => {
137            el.removeAttribute('disabled');
138            el.classList.remove('disabled');
139        });
140
141        // Remove question limit warnings
142        const limitWarnings = document.querySelectorAll('[class*="limit"], [class*="quota"]');
143        limitWarnings.forEach(warning => {
144            const text = warning.textContent.toLowerCase();
145            if (text.includes('limit') || text.includes('quota') || text.includes('reached')) {
146                warning.remove();
147                console.log('Removed limit warning');
148            }
149        });
150    }
151
152    // Add PDF download button
153    function addPDFDownloadButton() {
154        console.log('Adding PDF download button...');
155        
156        // Check if button already exists
157        if (document.querySelector('#prepmart-pdf-download-btn')) {
158            return;
159        }
160
161        // Create download button
162        const downloadBtn = document.createElement('button');
163        downloadBtn.id = 'prepmart-pdf-download-btn';
164        downloadBtn.innerHTML = '<i class="fa fa-download"></i> Download PDF';
165        downloadBtn.style.cssText = `
166            position: fixed;
167            bottom: 30px;
168            right: 30px;
169            z-index: 9999;
170            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
171            color: white;
172            border: none;
173            padding: 15px 25px;
174            border-radius: 50px;
175            font-size: 16px;
176            font-weight: bold;
177            cursor: pointer;
178            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
179            transition: all 0.3s ease;
180            display: flex;
181            align-items: center;
182            gap: 10px;
183        `;
184
185        // Add hover effect
186        downloadBtn.addEventListener('mouseenter', () => {
187            downloadBtn.style.transform = 'scale(1.05)';
188            downloadBtn.style.boxShadow = '0 6px 20px rgba(0, 0, 0, 0.4)';
189        });
190
191        downloadBtn.addEventListener('mouseleave', () => {
192            downloadBtn.style.transform = 'scale(1)';
193            downloadBtn.style.boxShadow = '0 4px 15px rgba(0, 0, 0, 0.3)';
194        });
195
196        // Add click handler for PDF download
197        downloadBtn.addEventListener('click', async () => {
198            console.log('PDF download initiated...');
199            
200            // Show loading state
201            const originalText = downloadBtn.innerHTML;
202            downloadBtn.innerHTML = '<i class="fa fa-spinner fa-spin"></i> Generating PDF...';
203            downloadBtn.disabled = true;
204
205            try {
206                // Get the main content area - try multiple selectors
207                let contentElement = document.querySelector('#questionaire') || 
208                                   document.querySelector('main') || 
209                                   document.querySelector('.container') || 
210                                   document.querySelector('#content') || 
211                                   document.body;
212
213                console.log('Content element selected:', contentElement.tagName, contentElement.id || contentElement.className);
214
215                // Create a wrapper div with proper styling
216                const wrapper = document.createElement('div');
217                wrapper.style.cssText = `
218                    width: 210mm;
219                    padding: 20px;
220                    background: white;
221                    color: black;
222                    font-family: Arial, sans-serif;
223                    font-size: 14px;
224                    line-height: 1.6;
225                `;
226
227                // Clone the content
228                const clonedContent = contentElement.cloneNode(true);
229
230                // Remove unwanted elements from clone
231                const unwantedSelectors = [
232                    '#prepmart-pdf-download-btn',
233                    'script',
234                    'nav',
235                    'header',
236                    'footer',
237                    '.modal',
238                    '.popup',
239                    '[class*="advertisement"]',
240                    'iframe',
241                    '.alert-div'
242                ];
243
244                unwantedSelectors.forEach(selector => {
245                    const elements = clonedContent.querySelectorAll(selector);
246                    elements.forEach(el => el.remove());
247                });
248
249                // Apply inline styles to preserve formatting
250                const allElements = clonedContent.querySelectorAll('*');
251                allElements.forEach(el => {
252                    try {
253                        const computedStyle = window.getComputedStyle(el);
254                        el.style.color = computedStyle.color || 'black';
255                        el.style.backgroundColor = computedStyle.backgroundColor;
256                        el.style.fontSize = computedStyle.fontSize;
257                        el.style.fontWeight = computedStyle.fontWeight;
258                        el.style.padding = computedStyle.padding;
259                        el.style.margin = computedStyle.margin;
260                        el.style.border = computedStyle.border;
261                    } catch (e) {
262                        // Skip elements that can't be styled
263                        console.log('Could not style element:', e);
264                    }
265                });
266
267                wrapper.appendChild(clonedContent);
268
269                // Configure PDF options for A4 size
270                const opt = {
271                    margin: [10, 10, 10, 10],
272                    filename: `prepmart-${Date.now()}.pdf`,
273                    image: { type: 'jpeg', quality: 0.98 },
274                    html2canvas: { 
275                        scale: 2,
276                        useCORS: true,
277                        logging: true,
278                        letterRendering: true,
279                        allowTaint: true,
280                        backgroundColor: '#ffffff'
281                    },
282                    jsPDF: { 
283                        unit: 'mm', 
284                        format: 'a4', 
285                        orientation: 'portrait' 
286                    },
287                    pagebreak: { mode: ['avoid-all', 'css', 'legacy'] }
288                };
289
290                // Generate PDF
291                console.log('Starting PDF generation...');
292                await html2pdf().set(opt).from(wrapper).save();
293                
294                console.log('PDF generated successfully');
295                
296                // Show success message
297                downloadBtn.innerHTML = '<i class="fa fa-check"></i> Downloaded!';
298                setTimeout(() => {
299                    downloadBtn.innerHTML = originalText;
300                    downloadBtn.disabled = false;
301                }, 2000);
302
303            } catch (error) {
304                console.error('PDF generation failed:', error);
305                downloadBtn.innerHTML = '<i class="fa fa-exclamation-triangle"></i> Failed';
306                setTimeout(() => {
307                    downloadBtn.innerHTML = originalText;
308                    downloadBtn.disabled = false;
309                }, 2000);
310            }
311        });
312
313        document.body.appendChild(downloadBtn);
314        console.log('PDF download button added');
315    }
316
317    // Main initialization function
318    function init() {
319        console.log('Initializing Prepmart Premium Unlocker...');
320        
321        // Remove subscription popup immediately
322        removeSubscriptionPopup();
323        
324        // Remove sign-in prompts
325        removeSignInPrompts();
326        
327        // Remove ads and banners
328        removeAdsAndBanners();
329        
330        // Unlock premium features
331        unlockPremiumFeatures();
332        
333        // Add PDF download button
334        addPDFDownloadButton();
335    }
336
337    // Run on page load
338    if (document.readyState === 'loading') {
339        document.addEventListener('DOMContentLoaded', init);
340    } else {
341        init();
342    }
343
344    // Watch for dynamic content changes
345    const observer = new MutationObserver(debounce(() => {
346        removeSubscriptionPopup();
347        removeSignInPrompts();
348        removeAdsAndBanners();
349        unlockPremiumFeatures();
350    }, 500));
351
352    // Start observing
353    observer.observe(document.body, {
354        childList: true,
355        subtree: true
356    });
357
358    console.log('Prepmart Premium Unlocker - Fully initialized');
359
360})();
Prepmart Premium Unlocker & PDF Exporter | Robomonkey