mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
public commit
This commit is contained in:
19
examples/sw/main.ts
Normal file
19
examples/sw/main.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.getRegistrations().then((registrations) => {
|
||||
for (const registration of registrations) {
|
||||
console.log("[-] unregister Service Worker");
|
||||
registration.unregister();
|
||||
}
|
||||
|
||||
navigator.serviceWorker
|
||||
.register("./sw.ts?t=" + Date.now(), {
|
||||
type: "module"
|
||||
})
|
||||
.then(() => console.log("[+] service Worker registered"))
|
||||
.catch((err) => console.error("[!] service Worker registration failed:", err));
|
||||
|
||||
navigator.serviceWorker.ready.then(() => {
|
||||
console.log("[√] service worker is ready and controlling the page.");
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user