Transaltor / sw.js
Aichatbot12321's picture
Upload 27 files
84e1dd3 verified
Raw History Blame Contribute Delete
2.76 kB
// 🚨 THE GLOBAL APP KILLSWITCH - BLOCKS GOOGLE ACROSS ALL HTML FILES 🚨
self.addEventListener('fetch', (event) => {
const url = event.request.url;
// If ANY file tries to send or pull data from Google or the Proxy...
if (url.includes('script.google.com') || url.includes('allorigins.win')) {
// ...Intercept it and return a fake "Success" instantly.
// Zero data leaves your device. The loops are neutralized.
event.respondWith(
new Response(JSON.stringify({ success: true, history: [] }), {
status: 200,
headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }
})
);
return;
}
});
const CACHE_NAME = 'deep-ai-pro-v4';
// 🚀 तुम्हारे सारे पेज यहाँ डाल दिए हैं!
const STATIC_ASSETS = [
'/', '/index.html', '/search.html', '/maths.html', '/style.css', '/nav-sidebar.js', '/main.js', '/manifest.json',
'/history.html', '/image.html', '/board.html', '/youtube.html', '/translator.html',
'/qa.html', '/quiz.html', '/lens.html', '/create.html', '/books.html', '/book_quiz.html',
'/tables.html', '/chess.html', '/runhtml.html'
];
self.addEventListener('install', (e) => {
self.skipWaiting();
e.waitUntil(caches.open(CACHE_NAME).then((cache) => cache.addAll(STATIC_ASSETS)));
});
self.addEventListener('activate', (e) => {
e.waitUntil(clients.claim());
e.waitUntil(
caches.keys().then((keys) => {
return Promise.all(keys.map((key) => {
if (key !== CACHE_NAME) return caches.delete(key);
}));
})
);
});
self.addEventListener('fetch', (e) => {
if (e.request.method !== 'GET') return;
e.respondWith(
fetch(e.request)
.then((response) => {
// Cache API can't store partial (206) responses - trying to
// was throwing an uncaught error on every audio/video range request.
if (response.status === 200 && response.type === 'basic') {
const resClone = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(e.request, resClone)).catch(() => {});
}
return response;
})
.catch(() => {
// 🔥 THE MAGIC FIX: ignoreSearch: true
// यह URL के आगे लगे ?session=123 को इग्नोर करके पेज को ऑफलाइन भी लोड कर देगा!
return caches.match(e.request, { ignoreSearch: true });
})
);
});