Add proof of concept adblocker and continue working on refining the use hook.
This commit is contained in:
parent
6f4f234c82
commit
b9f64617dd
5 changed files with 176 additions and 8 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 110 KiB |
|
|
@ -1 +0,0 @@
|
|||
console.log("Hello World!");
|
||||
166
public/marketplace/adblock/index.js
Normal file
166
public/marketplace/adblock/index.js
Normal file
File diff suppressed because one or more lines are too long
7
public/marketplace/adblock/index.js.map
Normal file
7
public/marketplace/adblock/index.js.map
Normal file
File diff suppressed because one or more lines are too long
10
public/sw.js
10
public/sw.js
|
|
@ -5,19 +5,16 @@ 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,
|
||||
});
|
||||
|
||||
function logContext(event) {
|
||||
console.log("Event:", event);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
ww.use({
|
||||
function: logContext,
|
||||
function: self.adblockExt.filterRequest,
|
||||
events: ["fetch"],
|
||||
name: "Adblock"
|
||||
});
|
||||
|
||||
const uv = new UVServiceWorker();
|
||||
|
|
@ -25,7 +22,6 @@ const uv = new UVServiceWorker();
|
|||
self.addEventListener("fetch", async (event) => {
|
||||
let mwResponse = await ww.run(event)();
|
||||
if (mwResponse.includes(null)) {
|
||||
console.log("Aborting Request!");
|
||||
return;
|
||||
}
|
||||
event.respondWith(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue