-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
50 lines (40 loc) · 1.41 KB
/
Copy pathbackground.js
File metadata and controls
50 lines (40 loc) · 1.41 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
// background.js - Service Worker for intercepting JS files
console.log('🚀 Aifiesta-1337 Service Worker started');
chrome.webRequest.onBeforeRequest.addListener(
function (details) {
const url = details.url;
// Intercept main JavaScript files
if (url.includes('.js') && (
url.includes('aifiesta') ||
url.includes('main') ||
url.includes('app') ||
url.includes('chunk')
)) {
console.log('🎯 Intercepting JS file:', url);
// Fetch, modify, and serve the patched version
fetchAndPatchJS(url);
// For now, let it load normally - we'll patch via content script
return {};
}
return {};
},
{ urls: ["*://chat.aifiesta.ai/*"] },
["requestBody"]
);
async function fetchAndPatchJS(url) {
try {
const response = await fetch(url);
const jsContent = await response.text();
// Patch isAdmin values
const patchedContent = jsContent
.replace(/isAdmin:\s*!1/g, 'isAdmin: !0')
.replace(/isAdmin:\s*false/g, 'isAdmin: true');
console.log('✅ JavaScript patched for:', url);
// Store patched content (simplified approach)
chrome.storage.local.set({
[`patched_${url}`]: patchedContent
});
} catch (error) {
console.error('💀 Failed to patch JS:', error);
}
}