From f60f5350ef38e01874fe40382d80f1395a92952f Mon Sep 17 00:00:00 2001 From: Oliver Atkinson Date: Fri, 13 Dec 2024 13:16:24 -0700 Subject: [PATCH] the extension as inteneded --- browser/background.js | 13 +++++++++++++ browser/main/main.html | 14 -------------- browser/manifest.json | 8 +++++++- browser/popup/inject.js | 13 ------------- browser/popup/popup.html | 5 ++--- browser/popup/popup.js | 21 --------------------- 6 files changed, 22 insertions(+), 52 deletions(-) create mode 100644 browser/background.js delete mode 100644 browser/main/main.html delete mode 100644 browser/popup/inject.js delete mode 100644 browser/popup/popup.js diff --git a/browser/background.js b/browser/background.js new file mode 100644 index 0000000..2e64fd3 --- /dev/null +++ b/browser/background.js @@ -0,0 +1,13 @@ +function handle(requestDetails) { + let b64 = btoa(requestDetails.url) + // let original = atob(b64); + // console.log(`Loading: ${requestDetails.url} || ${b64}`); + + return { + redirectUrl: `http://localhost:4433/s3/${b64}` + } +} + +browser.webRequest.onBeforeRequest.addListener( + handle, { urls: [""] }, ["blocking"] +); diff --git a/browser/main/main.html b/browser/main/main.html deleted file mode 100644 index 0a4ceb5..0000000 --- a/browser/main/main.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - -

Now click "load" in the extension window

- - - \ No newline at end of file diff --git a/browser/manifest.json b/browser/manifest.json index c1d8e0c..a3c44bd 100644 --- a/browser/manifest.json +++ b/browser/manifest.json @@ -4,8 +4,14 @@ "version": "0.1", "description": "Adds a red border to all webpages matching mozilla.org.", "permissions": [ - "activeTab" + "activeTab", + "webRequest", + "webRequestBlocking", + "" ], + "background": { + "scripts": ["background.js"] + }, "browser_action": { "default_icon": "icon.png", "default_title": "Click me!", diff --git a/browser/popup/inject.js b/browser/popup/inject.js deleted file mode 100644 index 225d980..0000000 --- a/browser/popup/inject.js +++ /dev/null @@ -1,13 +0,0 @@ - -let anchor = document.getElementById('anchor'); -if (anchor) { - window.fetch(anchor.innerText) - .then(res => res.text()) - .then((body) => { - document.body.textContent = ""; - document.body.innerHTML = body; - }) - - -} - diff --git a/browser/popup/popup.html b/browser/popup/popup.html index c5daa44..a46f286 100644 --- a/browser/popup/popup.html +++ b/browser/popup/popup.html @@ -5,10 +5,9 @@ - - + +

-