the extension as inteneded
This commit is contained in:
parent
2987221c93
commit
f60f5350ef
13
browser/background.js
Normal file
13
browser/background.js
Normal file
@ -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: ["<all_urls>"] }, ["blocking"]
|
||||||
|
);
|
@ -1,14 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<title></title>
|
|
||||||
<meta name="description" content="">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Now click "load" in the extension window</h1>
|
|
||||||
<div id="anchor" hidden></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -4,8 +4,14 @@
|
|||||||
"version": "0.1",
|
"version": "0.1",
|
||||||
"description": "Adds a red border to all webpages matching mozilla.org.",
|
"description": "Adds a red border to all webpages matching mozilla.org.",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"activeTab"
|
"activeTab",
|
||||||
|
"webRequest",
|
||||||
|
"webRequestBlocking",
|
||||||
|
"<all_urls>"
|
||||||
],
|
],
|
||||||
|
"background": {
|
||||||
|
"scripts": ["background.js"]
|
||||||
|
},
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"default_icon": "icon.png",
|
"default_icon": "icon.png",
|
||||||
"default_title": "Click me!",
|
"default_title": "Click me!",
|
||||||
|
@ -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;
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -5,10 +5,9 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<button id="newtab">Open canvas</button>
|
<button id="">On</button>
|
||||||
<button id="replacer">Load page</button>
|
<button id="">Off</button>
|
||||||
<p id="output"></p>
|
<p id="output"></p>
|
||||||
<script src="popup.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
const output = document.getElementById('output');
|
|
||||||
let page_url = "http://127.0.0.1:4433/s3/style.css";
|
|
||||||
|
|
||||||
document.getElementById("newtab").addEventListener('click', async function(e) {
|
|
||||||
browser.tabs.create({ url: "/main/main.html" }).then((t) => {
|
|
||||||
if (t.id) {
|
|
||||||
output.innerText += t.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
document.getElementById("replacer").addEventListener('click', async function(e) {
|
|
||||||
browser.tabs.executeScript({ code: injection })
|
|
||||||
browser.tabs.executeScript({ file: "inject.js" });
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
const injection = `
|
|
||||||
let head = document.getElementById('anchor');
|
|
||||||
head.innerText = "${page_url}";
|
|
||||||
`
|
|
Loading…
Reference in New Issue
Block a user