diff --git a/public/marketplace/adblock/adblock.png b/public/marketplace/adblock/adblock.png new file mode 100644 index 0000000..1d181b8 Binary files /dev/null and b/public/marketplace/adblock/adblock.png differ diff --git a/public/sw.js b/public/sw.js index 717738c..203462c 100644 --- a/public/sw.js +++ b/public/sw.js @@ -5,17 +5,35 @@ importScripts("/uv/uv.bundle.js"); importScripts("/uv.config.js"); importScripts(__uv$config.sw); importScripts("./workerware/workerware.js"); -importScripts("./marketplace/adblock/index.js") const ww = new WorkerWare({ debug: true, }); -ww.use({ - function: self.adblockExt.filterRequest, - events: ["fetch"], - name: "Adblock" -}); +function loadExtensionScripts() { + try { + let db = indexedDB.open("AluDB", 1); + db.onsuccess = () => { + let transaction = db.result.transaction("InstalledExtensions", "readonly"); + let store = transaction.objectStore("InstalledExtensions"); + let request = store.getAll(); + request.onsuccess = () => { + let extensions = request.result; + extensions.forEach((extension) => { + eval(atob(extension.script)); + ww.use({ + function: self[extension.entryNamespace][extension.entryFunc], + name: extension.title, + events: ["fetch"], + }); // Use extension middleware + }); + }; + }; + } catch (err) { + console.error(`Failed load extension scripts: ${err}`); + } +} +loadExtensionScripts(); const uv = new UVServiceWorker(); diff --git a/src/components/ProxyRegistrar.astro b/src/components/ProxyRegistrar.astro index c37b35b..9d61fd9 100644 --- a/src/components/ProxyRegistrar.astro +++ b/src/components/ProxyRegistrar.astro @@ -295,7 +295,7 @@ } } - function updateProxiedFavicon(iframe: HTMLIFrameElement, hasErrored = false) { + function updateProxiedFavicon(iframe: HTMLIFrameElement) { if (!iframe) return; let proxiedFavicon = document.getElementById("proxied-favicon") as HTMLImageElement; if (iframe) { diff --git a/src/json/marketplace.json b/src/json/marketplace.json index b6c6ebc..635547e 100644 --- a/src/json/marketplace.json +++ b/src/json/marketplace.json @@ -3,12 +3,8 @@ "title": "Adblocker", "version": "0.0.1", "image": "/marketplace/adblock/adblock.png", - "script": "/marketplace/adblock/adblocker.js" - }, - "dev.wearr.adblock2": { - "title": "Adblocker2", - "version": "0.0.2", - "image": "/marketplace/adblock/adblock.png", - "script": "/marketplace/adblock/adblocker.js" + "script": "/marketplace/adblock/index.js", + "entryNamespace": "adblockExt", + "entryFunc": "filterRequest" } } diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index ba624ed..72f611d 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -58,7 +58,7 @@ const { title, optionalPreloads } = Astro.props;