This commit is contained in:
Jonathan Wyss 2024-03-14 22:11:08 +01:00
commit 67bd4e2c28
7 changed files with 89 additions and 0 deletions

15
background.js Normal file
View File

@ -0,0 +1,15 @@
let backgroundPage = browser.extension.getBackgroundPage();
function failure(value)
{
console.log("tabs.create returned a failure");
}
browser.browserAction.onClicked.addListener(() => {
let promise = browser.tabs.create({"url": "home.html"});
//promise.then((value) => run(value),()=> failure(value));
});

10
home.html Normal file
View File

@ -0,0 +1,10 @@
<html>
<body>
test
<button type="submit" id="id_run" value="run importer" name="b_submit">RUNRUNRUN</button>
<script type="text/javascript" language="javascript" src="home.js"></script>
</body>
</html>

9
home.js Normal file
View File

@ -0,0 +1,9 @@
function run()
{
document.getElementById("id_run").addEventListener("click", function(e){
console.log("triggered!!");
alert("judihudi");
e.preventDefault();
});
}
window.onload = run;

BIN
icons/border-48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

25
manifest.json Normal file
View File

@ -0,0 +1,25 @@
{
"manifest_version": 2,
"name": "yt",
"version": "1.0",
"description": "Adds a red border to all webpages matching mozilla.org.",
"web_accessible_resources":["newpipe_subscriptions_202403101004.json"],
"permissions":["tabs"],
"icons": {
"48": "icons/border-48.png"
},
"browser_action":{
"default_title":"Jonnis yt plugin",
"default_icon":{
"48":"icons/border-48.png"
}
},
"background":{
"scripts": ["background.js"]
}
}

File diff suppressed because one or more lines are too long

29
yt.js Normal file
View File

@ -0,0 +1,29 @@
document.body.style.border = "5px solid red";
const filePath = "newpipe_subscriptions_202403101004.json";
var localURL = browser.extension.getURL(filePath);
var w=[];
fetch(localURL)
.then((res) => {
if(!res.ok){
throw new Error
(`res error`);
}
return res.json();
})
.then((data) => {
for(let i=0;i<3;i++) //i in data.subscriptions)
{
let open=null;
console.log(data.subscriptions[i].url);
try{
open = alert(data.subscriptions[i].url,"_blank");
}
catch(e) {InsertError(e.description);}
}
})
.catch((error)=> console.error("couldnt fetch data",error));