trying to figure out a way to display this data
This commit is contained in:
BIN
browser/icon.png
Normal file
BIN
browser/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
5
browser/jsconfig.json
Normal file
5
browser/jsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"typeAcquisition": {
|
||||
"include": ["firefox-webext-browser"]
|
||||
}
|
||||
}
|
14
browser/main/main.html
Normal file
14
browser/main/main.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!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>
|
14
browser/manifest.json
Normal file
14
browser/manifest.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Viewer",
|
||||
"version": "0.1",
|
||||
"description": "Adds a red border to all webpages matching mozilla.org.",
|
||||
"permissions": [
|
||||
"activeTab"
|
||||
],
|
||||
"browser_action": {
|
||||
"default_icon": "icon.png",
|
||||
"default_title": "Click me!",
|
||||
"default_popup": "popup/popup.html"
|
||||
}
|
||||
}
|
13
browser/popup/inject.js
Normal file
13
browser/popup/inject.js
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
let anchor = document.getElementById('anchor');
|
||||
if (anchor) {
|
||||
window.fetch(anchor.innerText)
|
||||
.then(res => res.text())
|
||||
.then((body) => {
|
||||
document.body.textContent = "";
|
||||
document.body.innerHTML = body;
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
23
browser/popup/popup.html
Normal file
23
browser/popup/popup.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<button id="newtab">Open canvas</button>
|
||||
<button id="replacer">Load page</button>
|
||||
<p id="output"></p>
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
<style>
|
||||
html {
|
||||
background: darkolivegreen;
|
||||
color: azure;
|
||||
}
|
||||
body {
|
||||
height: 200px;
|
||||
width: 200px;
|
||||
}
|
||||
</style>
|
||||
</html>
|
21
browser/popup/popup.js
Normal file
21
browser/popup/popup.js
Normal file
@@ -0,0 +1,21 @@
|
||||
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}";
|
||||
`
|
Reference in New Issue
Block a user