Size
5.5 KB
Version
1.0.1
Created
Mar 3, 2026
Updated
about 1 month ago
1// ==UserScript==
2// @name Lovable Unlimited Credits
3// @description Créditos ilimitados para Lovable
4// @version 1.0.1
5// @match https://*.lovable.dev/*
6// @match https://lovable.dev/*
7// @icon https://lovable.dev/favicon.ico
8// @grant GM.getValue
9// @grant GM.setValue
10// ==/UserScript==
11(function() {
12 'use strict';
13
14 console.log('Lovable Unlimited Credits - Extension loaded');
15
16 // Function to modify credits display
17 function modifyCreditsDisplay() {
18 // Find the credits display element
19 const creditsElement = document.querySelector('div.text-sm.font-normal.text-foreground');
20
21 if (creditsElement && creditsElement.textContent.includes('credits remaining')) {
22 creditsElement.textContent = '∞ unlimited credits available';
23 creditsElement.style.color = '#10b981'; // Green color
24 creditsElement.style.fontWeight = 'bold';
25 console.log('Credits display modified to unlimited');
26 }
27 }
28
29 // Function to intercept and modify fetch requests
30 const originalFetch = window.fetch;
31 window.fetch = async function(...args) {
32 const response = await originalFetch.apply(this, args);
33
34 // Clone the response to read it
35 const clonedResponse = response.clone();
36
37 try {
38 const url = args[0];
39
40 // Check if this is a credits-related API call
41 if (typeof url === 'string' && (url.includes('credit') || url.includes('usage') || url.includes('limit'))) {
42 const data = await clonedResponse.json();
43
44 // Modify the response to show unlimited credits
45 const modifiedData = {
46 ...data,
47 credits: 999999,
48 creditsRemaining: 999999,
49 creditsUsed: 0,
50 limit: 999999,
51 hasUnlimitedCredits: true
52 };
53
54 console.log('Intercepted credits API call, returning unlimited credits');
55
56 // Return a new response with modified data
57 return new Response(JSON.stringify(modifiedData), {
58 status: response.status,
59 statusText: response.statusText,
60 headers: response.headers
61 });
62 }
63 } catch (e) {
64 // If parsing fails, just return the original response
65 console.log('Could not parse response, returning original');
66 }
67
68 return response;
69 };
70
71 // Function to intercept XMLHttpRequest
72 const originalXHROpen = XMLHttpRequest.prototype.open;
73 const originalXHRSend = XMLHttpRequest.prototype.send;
74
75 XMLHttpRequest.prototype.open = function(method, url, ...rest) {
76 this._url = url;
77 return originalXHROpen.apply(this, [method, url, ...rest]);
78 };
79
80 XMLHttpRequest.prototype.send = function(...args) {
81 const xhr = this;
82
83 // Store original onload handler
84 const originalOnLoad = xhr.onload;
85
86 xhr.onload = function() {
87 try {
88 if (xhr._url && (xhr._url.includes('credit') || xhr._url.includes('usage') || xhr._url.includes('limit'))) {
89 const response = JSON.parse(xhr.responseText);
90
91 // Modify response
92 const modifiedResponse = {
93 ...response,
94 credits: 999999,
95 creditsRemaining: 999999,
96 creditsUsed: 0,
97 limit: 999999,
98 hasUnlimitedCredits: true
99 };
100
101 // Override response properties
102 Object.defineProperty(xhr, 'responseText', {
103 writable: true,
104 value: JSON.stringify(modifiedResponse)
105 });
106
107 Object.defineProperty(xhr, 'response', {
108 writable: true,
109 value: JSON.stringify(modifiedResponse)
110 });
111
112 console.log('Intercepted XHR credits call, returning unlimited credits');
113 }
114 } catch (e) {
115 console.log('Could not modify XHR response');
116 }
117
118 if (originalOnLoad) {
119 originalOnLoad.apply(this, arguments);
120 }
121 };
122
123 return originalXHRSend.apply(this, args);
124 };
125
126 // Observer to watch for DOM changes and update credits display
127 const observer = new MutationObserver(function(mutations) {
128 modifyCreditsDisplay();
129 });
130
131 // Start observing when DOM is ready
132 function init() {
133 console.log('Initializing Lovable Unlimited Credits');
134
135 // Initial modification
136 modifyCreditsDisplay();
137
138 // Observe for changes
139 observer.observe(document.body, {
140 childList: true,
141 subtree: true,
142 characterData: true
143 });
144
145 // Periodic check every 2 seconds
146 setInterval(modifyCreditsDisplay, 2000);
147 }
148
149 // Wait for page to load
150 if (document.readyState === 'loading') {
151 document.addEventListener('DOMContentLoaded', init);
152 } else {
153 init();
154 }
155
156 console.log('Lovable Unlimited Credits - Setup complete');
157})();