Compare commits

...

4 Commits

Author SHA1 Message Date
vuk
aa71f952ec let's try indexdb 2024-11-04 23:42:55 +01:00
vuk
31b725dfc6 milje.js now outputs the version number from the manifest file(testing something out) 2024-09-22 14:03:01 +02:00
Vuk Savić
a009f6425c Merge pull request #1 from miljegen/js-edit
JS edit
2024-09-11 21:26:32 +02:00
ddfe7e7a91 JS edit 2024-09-11 21:17:24 +02:00
6 changed files with 135 additions and 26 deletions

13
Makefile Normal file
View File

@@ -0,0 +1,13 @@
ENCODED_IMAGES := $(wildcard assets/*.png.64)
IMAGES := $(patsubst assets/%.png.64, images/%.png, $(ENCODED_IMAGES))
out: $(IMAGES)
images/:
mkdir $@
echo '*' > images/.gitignore
images/%.png: assets/%.png.64 | images/
base64 -d $< > $@

View File

@@ -3,10 +3,14 @@
"name": "browser-milje",
"description": "adds a milje table cloth on top of your browser viewport",
"version": "0.0.2",
"permissions": ["storage", "activeTab", "scripting"],
"action": {
"default_popup": "popup.html",
"default_icon": "assets/browser-milje.png"
},
"background": {
"service_worker": "background.js"
},
"icons": {
"16": "assets/icon-16.png",
"32": "assets/icon-32.png",
@@ -15,9 +19,13 @@
},
"content_scripts": [
{
"matches": ["<all_urls>", "file:///"],
"js": ["scripts/milje.js"]
"js": ["scripts/milje.js", "scripts/contentScript.js"]
}
]
],
"browser_specific_settings": {
"gecko": {
"id": ""
}
}
}

View File

@@ -25,6 +25,11 @@
<body>
<h1>browser-milje!</h1>
<img id="milje" src="assets/milje.png" alt="this should represent the milje">
<input type="file" id="fileInput" accept="image/*">
<button id="uploadButton">upload milje!</button>
<div id="miljeGallery">
</div>
<script src="milje.js"></script>
</body>
</html>

5
scripts/contentScript.js Normal file
View File

@@ -0,0 +1,5 @@
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.type === "setMilje") {
document.body.style.background = `url(${message.milje})`;
}
});

File diff suppressed because one or more lines are too long

13
scripts/popup.js Normal file
View File

@@ -0,0 +1,13 @@
document.getElementById('uploadButton').addEventListener('click', async () => {
const miljeInput = document.getElementById('fileInput');
const milje = miljeInput.files[0];
if(!milje) {
alert("Please select a milje.");
return;
}
const base64Milje = await convertImageToBase64(milje);
await saveImage(base64Milje);
await displayImage(base64Milje);
})