PrepMart Unlimited Access

A new extension

Size

11.9 KB

Version

1.1.2

Created

Nov 7, 2025

Updated

about 1 month ago

1// ==UserScript==
2// @name		PrepMart Unlimited Access
3// @description		A new extension
4// @version		1.1.2
5// @match		https://*.prepmart.in/*
6// @icon		https://www.prepmart.in/prepmart-favicon.png?1761906642
7// @require		https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js
8// @require		https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js
9// ==/UserScript==
10(function() {
11    'use strict';
12
13    console.log('PrepMart Unlimited Access extension loaded');
14
15    // Function to hide subscription popup
16    function hideSubscriptionPopup() {
17        const popup = document.querySelector('#subscriptionPopup');
18        if (popup) {
19            popup.style.display = 'none';
20            popup.classList.remove('show');
21            console.log('Subscription popup hidden');
22        }
23
24        // Remove modal backdrop if exists
25        const backdrop = document.querySelector('.modal-backdrop');
26        if (backdrop) {
27            backdrop.remove();
28            console.log('Modal backdrop removed');
29        }
30
31        // Restore body scroll
32        document.body.classList.remove('modal-open');
33        document.body.style.overflow = '';
34        document.body.style.paddingRight = '';
35    }
36
37    // Function to remove login button
38    function removeLoginButton() {
39        const loginButton = document.querySelector('.buttons a[href="/userLogin.php"]');
40        if (loginButton) {
41            loginButton.remove();
42            console.log('Login button removed');
43        }
44
45        // Also remove the entire buttons div if it only contains login
46        const buttonsDiv = document.querySelector('.buttons');
47        if (buttonsDiv && buttonsDiv.children.length === 0) {
48            buttonsDiv.remove();
49            console.log('Empty buttons container removed');
50        }
51    }
52
53    // Function to bypass question limits
54    function bypassQuestionLimits() {
55        // Remove any question limit overlays or restrictions
56        const limitOverlays = document.querySelectorAll('[class*="limit"], [class*="restrict"], [id*="limit"], [id*="restrict"]');
57        limitOverlays.forEach(overlay => {
58            if (overlay.textContent.toLowerCase().includes('limit') || 
59                overlay.textContent.toLowerCase().includes('subscribe') ||
60                overlay.textContent.toLowerCase().includes('premium')) {
61                overlay.remove();
62                console.log('Question limit overlay removed:', overlay);
63            }
64        });
65
66        // Unlock all questions by removing disabled states
67        const disabledElements = document.querySelectorAll('[disabled], .disabled, [class*="locked"], [class*="premium"]');
68        disabledElements.forEach(element => {
69            element.removeAttribute('disabled');
70            element.classList.remove('disabled', 'locked', 'premium');
71        });
72
73        // Make all links clickable
74        const restrictedLinks = document.querySelectorAll('a[onclick*="subscribe"], a[onclick*="login"], a[onclick*="premium"]');
75        restrictedLinks.forEach(link => {
76            link.removeAttribute('onclick');
77            link.style.pointerEvents = 'auto';
78            link.style.opacity = '1';
79        });
80
81        console.log('Question limits bypassed');
82    }
83
84    // Function to remove subscription-related elements
85    function removeSubscriptionElements() {
86        // Remove any subscription banners or cards
87        const subscriptionElements = document.querySelectorAll('[class*="subscription"], [class*="pricing"], [id*="subscription"], [id*="pricing"]');
88        subscriptionElements.forEach(element => {
89            // Don't remove the popup itself (we just hide it), but remove other subscription elements
90            if (element.id !== 'subscriptionPopup') {
91                element.remove();
92                console.log('Subscription element removed:', element);
93            }
94        });
95    }
96
97    // Function to create and add download PDF button
98    function addDownloadButton() {
99        // Check if button already exists
100        if (document.getElementById('prepmart-pdf-download-btn')) {
101            console.log('Download button already exists');
102            return;
103        }
104
105        // Create download button
106        const downloadBtn = document.createElement('button');
107        downloadBtn.id = 'prepmart-pdf-download-btn';
108        downloadBtn.innerHTML = '📥 Download PDF';
109        downloadBtn.style.cssText = `
110            position: fixed;
111            top: 100px;
112            right: 20px;
113            z-index: 9999;
114            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
115            color: white;
116            border: none;
117            padding: 12px 24px;
118            border-radius: 8px;
119            font-size: 16px;
120            font-weight: bold;
121            cursor: pointer;
122            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
123            transition: all 0.3s ease;
124        `;
125
126        // Add hover effect
127        downloadBtn.addEventListener('mouseenter', function() {
128            this.style.transform = 'translateY(-2px)';
129            this.style.boxShadow = '0 6px 20px rgba(0, 0, 0, 0.3)';
130        });
131
132        downloadBtn.addEventListener('mouseleave', function() {
133            this.style.transform = 'translateY(0)';
134            this.style.boxShadow = '0 4px 15px rgba(0, 0, 0, 0.2)';
135        });
136
137        // Add click handler
138        downloadBtn.addEventListener('click', async function() {
139            await downloadPageAsPDF();
140        });
141
142        document.body.appendChild(downloadBtn);
143        console.log('Download PDF button added');
144    }
145
146    // Function to download page as PDF
147    async function downloadPageAsPDF() {
148        try {
149            const downloadBtn = document.getElementById('prepmart-pdf-download-btn');
150            const originalText = downloadBtn.innerHTML;
151            downloadBtn.innerHTML = '⏳ Generating PDF...';
152            downloadBtn.disabled = true;
153
154            console.log('Starting PDF generation...');
155
156            // Scroll to top first
157            window.scrollTo(0, 0);
158            await new Promise(resolve => setTimeout(resolve, 300));
159
160            // Get the entire page body for capture
161            const contentElement = document.body;
162
163            console.log('Content element selected:', contentElement.tagName);
164
165            // Temporarily hide the download button so it doesn't appear in PDF
166            downloadBtn.style.display = 'none';
167
168            // Wait for any dynamic content to load
169            await new Promise(resolve => setTimeout(resolve, 500));
170
171            // Use html2canvas to capture the content
172            const canvas = await html2canvas(contentElement, {
173                scale: 1.5,
174                useCORS: true,
175                allowTaint: true,
176                logging: true,
177                backgroundColor: '#ffffff',
178                windowWidth: document.documentElement.scrollWidth,
179                windowHeight: document.documentElement.scrollHeight,
180                width: document.documentElement.scrollWidth,
181                height: document.documentElement.scrollHeight,
182                x: 0,
183                y: 0
184            });
185
186            console.log('Canvas created successfully. Size:', canvas.width, 'x', canvas.height);
187
188            // Show the button again
189            downloadBtn.style.display = '';
190
191            // Check if canvas has content
192            if (canvas.width === 0 || canvas.height === 0) {
193                throw new Error('Canvas is empty - no content captured');
194            }
195
196            // A4 dimensions in mm
197            const a4Width = 210;
198            const a4Height = 297;
199
200            // Create PDF with A4 dimensions
201            const { jsPDF } = window.jspdf;
202            const pdf = new jsPDF({
203                orientation: 'portrait',
204                unit: 'mm',
205                format: 'a4'
206            });
207
208            // Calculate dimensions to fit content on A4
209            const imgWidth = a4Width;
210            const imgHeight = (canvas.height * imgWidth) / canvas.width;
211
212            let heightLeft = imgHeight;
213            let position = 0;
214
215            // Add image to PDF
216            const imgData = canvas.toDataURL('image/png');
217            
218            console.log('Image data length:', imgData.length);
219            
220            pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
221            heightLeft -= a4Height;
222
223            // Add new pages if content is longer than one page
224            while (heightLeft > 0) {
225                position = heightLeft - imgHeight;
226                pdf.addPage();
227                pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
228                heightLeft -= a4Height;
229            }
230
231            // Generate filename from page title
232            const pageTitle = document.title.replace(/[^a-z0-9]/gi, '_').toLowerCase();
233            const filename = `prepmart_${pageTitle}_${Date.now()}.pdf`;
234
235            // Save the PDF
236            pdf.save(filename);
237
238            console.log('PDF downloaded successfully:', filename);
239
240            // Reset button
241            downloadBtn.innerHTML = '✅ Downloaded!';
242            setTimeout(() => {
243                downloadBtn.innerHTML = originalText;
244                downloadBtn.disabled = false;
245            }, 2000);
246
247        } catch (error) {
248            console.error('Error generating PDF:', error);
249            const downloadBtn = document.getElementById('prepmart-pdf-download-btn');
250            if (downloadBtn) {
251                downloadBtn.style.display = '';
252                downloadBtn.innerHTML = '❌ Error - Try Again';
253                downloadBtn.disabled = false;
254                setTimeout(() => {
255                    downloadBtn.innerHTML = '📥 Download PDF';
256                }, 3000);
257            }
258        }
259    }
260
261    // Initialize the extension
262    function init() {
263        console.log('Initializing PrepMart Unlimited Access...');
264        
265        // Hide subscription popup immediately
266        hideSubscriptionPopup();
267        
268        // Remove login button
269        removeLoginButton();
270        
271        // Bypass question limits
272        bypassQuestionLimits();
273        
274        // Remove subscription elements
275        removeSubscriptionElements();
276
277        // Add download PDF button
278        addDownloadButton();
279    }
280
281    // Run on page load
282    if (document.readyState === 'loading') {
283        document.addEventListener('DOMContentLoaded', init);
284    } else {
285        init();
286    }
287
288    // Watch for dynamic content changes
289    const observer = new MutationObserver(function() {
290        // Check if subscription popup appears
291        const popup = document.querySelector('#subscriptionPopup.show');
292        if (popup) {
293            hideSubscriptionPopup();
294        }
295
296        // Check if login button reappears
297        const loginButton = document.querySelector('.buttons a[href="/userLogin.php"]');
298        if (loginButton) {
299            removeLoginButton();
300        }
301
302        // Continuously bypass any new restrictions
303        bypassQuestionLimits();
304
305        // Ensure download button exists
306        addDownloadButton();
307    });
308
309    // Start observing the document
310    observer.observe(document.body, {
311        childList: true,
312        subtree: true,
313        attributes: true,
314        attributeFilter: ['class', 'style']
315    });
316
317    // Prevent popup from showing via JavaScript
318    window.addEventListener('load', function() {
319        // Override Bootstrap modal show function if it exists
320        if (typeof window.bootstrap !== 'undefined' && window.bootstrap.Modal) {
321            const originalShow = window.bootstrap.Modal.prototype.show;
322            window.bootstrap.Modal.prototype.show = function() {
323                const modalElement = this._element;
324                if (modalElement && modalElement.id === 'subscriptionPopup') {
325                    console.log('Blocked subscription popup from showing');
326                    return;
327                }
328                return originalShow.apply(this, arguments);
329            };
330        }
331    });
332
333    console.log('PrepMart Unlimited Access extension initialized successfully');
334})();
PrepMart Unlimited Access | Robomonkey