-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinject.js
More file actions
308 lines (250 loc) · 11.3 KB
/
Copy pathinject.js
File metadata and controls
308 lines (250 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
// content.js - Aifiesta-1337 Security Assessment Tool
'use strict';
// Store original functions
const originalFetch = window.fetch;
const originalSetItem = localStorage.setItem;
// Enhanced logging with multiple colors
function logMessage(emoji, type, message, data = '') {
console.log(
`%c${emoji} %c[${type}] %c${message}`,
'font-size: 14px;',
'color: #ff6b00; font-weight: bold;',
'color: #029f60ff;',
data
);
}
// UUID v4 generator
function generateRandomUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const randomValue = Math.random() * 16 | 0;
const hexValue = c === 'x' ? randomValue : (randomValue & 0x3 | 0x8);
return hexValue.toString(16);
});
}
// Patch localStorage auth token to prevent email loops
async function patchSupabaseAuthToken() {
try {
const authTokenKey = 'sb-ubipcxqbjqyzcisxiugn-auth-token';
const authTokenData = localStorage.getItem(authTokenKey);
if (authTokenData) {
const parsedAuthData = JSON.parse(authTokenData);
if (parsedAuthData.user && parsedAuthData.user.user_metadata && !parsedAuthData.user.user_metadata.payment_email_sent_at) {
const currentTimestamp = new Date().toISOString();
parsedAuthData.user.user_metadata.payment_email_sent_at = currentTimestamp;
localStorage.setItem(authTokenKey, JSON.stringify(parsedAuthData));
logMessage('🔑', 'PATCH', 'Auth token patched with payment_email_sent_at');
}
}
} catch (error) {
logMessage('💀', 'ERROR', 'Failed to patch auth token:', error.message);
}
}
// Hook localStorage to re-patch when token updates
function hookLocalStorageUpdates() {
localStorage.setItem = function (storageKey, storageValue) {
const setItemResult = originalSetItem.apply(this, arguments);
if (storageKey === 'sb-ubipcxqbjqyzcisxiugn-auth-token') {
setTimeout(patchSupabaseAuthToken, 100);
}
return setItemResult;
};
logMessage('🪝', 'HOOK', 'localStorage.setItem hooked successfully');
}
// Blur email input
async function blurEmailInput() {
const emailInput = document.querySelector('input[type="email"]#email');
if (emailInput && !emailInput.dataset.blurred) {
emailInput.dataset.blurred = 'true';
emailInput.style.cssText = 'filter: blur(4px) !important';
logMessage('👁️', 'BLUR', 'Email input blurred and anonymized');
}
}
// Transform subscription button to premium success state
async function transformSubscriptionButton() {
const allButtons = Array.from(document.querySelectorAll('button'));
const manageSubscriptionButton = allButtons.find(button =>
button.textContent.includes('Manage Subscription')
);
if (manageSubscriptionButton && !manageSubscriptionButton.dataset.hooked) {
manageSubscriptionButton.dataset.hooked = 'true';
manageSubscriptionButton.onclick = function (event) {
event.preventDefault();
event.stopPropagation();
manageSubscriptionButton.style.cssText = `
background: linear-gradient(135deg, #2AA3B3, #4CB779) !important;
border-color: #059669 !important;
color: white !important;
cursor: default !important;
transition: all 0.5s ease !important;
`;
const checkmarkIcon = `
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-badge-check-icon lucide-badge-check w-4 h-4 mr-2"><path d="M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z"/><path d="m9 12 2 2 4-4"/></svg>
`;
manageSubscriptionButton.innerHTML = `${checkmarkIcon}You are already premium`;
manageSubscriptionButton.onclick = function (e) {
e.preventDefault();
e.stopPropagation();
return false;
};
logMessage('✅', 'CLICK', 'Subscription button clicked and transformed to premium state');
return false;
};
logMessage('🎯', 'HOOK', 'Manage Subscription button click handler attached');
}
}
// Watch for DOM changes to catch dynamically loaded buttons
function watchForSubscriptionButton() {
const startObserver = () => {
const observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
setTimeout(transformSubscriptionButton, 100);
setTimeout(blurEmailInput, 100);
}
});
});
observer.observe(document.documentElement, {
childList: true,
subtree: true
});
logMessage('👀', 'WATCH', 'DOM observer started for subscription button');
};
startObserver();
}
// Monkey patch fetch function for API interception
async function setupFetchInterceptor() {
window.fetch = async function (requestUrl, requestOptions) {
// Check for subscription API call
if (requestUrl.includes('user_subscriptions')) {
logMessage('🎯', 'INTERCEPT', 'Subscription API call detected.');
try {
const originalResponse = await originalFetch.apply(this, arguments);
const originalData = await originalResponse.clone().json();
logMessage('📸', 'CAPTURE', 'Original response captured.', originalData);
const modifiedData = {
user_id: generateRandomUUID(),
id: generateRandomUUID(),
plan_type: "premium", // paid would trigger refresh_token loop due to payment_email_sent_at missing
tokens_limit: 999999999,
messages_used: 0,
messages_limit: null,
provider_subscription_id: generateRandomUUID(),
provider: "stripe",
subscription_status: "active"
};
logMessage('🛡️', 'MODIFY', 'Response modified successfully.', modifiedData);
return new Response(JSON.stringify(modifiedData), {
status: originalResponse.status,
statusText: originalResponse.statusText,
headers: originalResponse.headers
});
} catch (error) {
logMessage('💀', 'ERROR', 'Modification failed, returning original.', error.message);
return originalFetch.apply(this, arguments);
}
}
// Check for users API call
if (requestUrl.includes('/v1/users')) {
logMessage('🎯', 'INTERCEPT', 'Users API call detected.');
try {
const originalResponse = await originalFetch.apply(this, arguments);
const originalData = await originalResponse.clone().json();
logMessage('📸', 'CAPTURE', 'Original users response captured.', originalData);
// Modify user data
const modifiedData = {
...originalData,
email: "admin@aifiesta.ai",
name: "Dhruv Rathee",
display_name: "Dhruv Rathee",
full_name: "Dhruv Rathee"
};
logMessage('🛡️', 'MODIFY', 'Users response modified successfully.', modifiedData);
return new Response(JSON.stringify(modifiedData), {
status: originalResponse.status,
statusText: originalResponse.statusText,
headers: originalResponse.headers
});
} catch (error) {
logMessage('💀', 'ERROR', 'Users modification failed, returning original.', error.message);
return originalFetch.apply(this, arguments);
}
}
// Check for message-count API call
if (requestUrl.includes('message-count')) {
logMessage('🚫', 'BLOCK', 'Message-count API call blocked.');
return new Response(JSON.stringify({
message: "ok"
}), {
status: 200,
statusText: "OK",
headers: {
'Content-Type': 'application/json'
}
});
}
// Check for customer portal API call
if (requestUrl.includes('functions/v1/customer-portal')) {
logMessage('💳', 'BLOCK', 'Customer portal API call blocked.');
const portalResponse = {
url: "https://chat.aifiesta.ai/",
success: true,
data: {
portal_url: "https://chat.aifiesta.ai/",
session_id: `portal_session_${generateRandomUUID()}`,
provider: "stripe",
expires_at: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(),
customer_id: `cus_${generateRandomUUID().substring(0, 14)}`
}
};
return new Response(JSON.stringify(portalResponse), {
status: 200,
statusText: "OK",
headers: {
'Content-Type': 'application/json'
}
});
}
// Check for payment-email API call
if (requestUrl.includes('functions/v1/payment-email')) {
logMessage('📧', 'BLOCK', 'Payment email API call blocked.');
return new Response(JSON.stringify({
message: "ok"
}), {
status: 400,
statusText: "OK",
headers: {
'Content-Type': 'application/json'
}
});
}
// Pass through all other requests unchanged
return originalFetch.apply(this, arguments);
};
logMessage('🔌', 'SETUP', 'Fetch interceptor installed successfully');
}
// Initialize the extension
async function initializeAifiesta1337() {
logMessage('👻', 'INIT', 'Aifiesta-1337 starting initialization...');
// Patch auth token immediately
await patchSupabaseAuthToken();
// Hook localStorage for future token updates
hookLocalStorageUpdates();
// Setup fetch interceptor for API calls
await setupFetchInterceptor();
// Start watching for DOM changes immediately
watchForSubscriptionButton();
// Wait for DOM to be ready for button transformation
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', async () => {
await transformSubscriptionButton();
await blurEmailInput();
logMessage('🚀', 'READY', 'Aifiesta-1337 fully loaded and operational!');
});
} else {
await transformSubscriptionButton();
await blurEmailInput();
logMessage('🚀', 'READY', 'Aifiesta-1337 fully loaded and operational!');
}
}
// Start the extension
initializeAifiesta1337();