mirror of
https://github.com/miljegen/browser-milje.git
synced 2025-08-31 08:23:44 +00:00
Compare commits
4 Commits
ff839b5333
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
aa71f952ec | ||
|
31b725dfc6 | ||
|
a009f6425c | ||
ddfe7e7a91 |
13
Makefile
Normal file
13
Makefile
Normal 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 $< > $@
|
||||
|
||||
|
||||
|
@@ -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": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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
5
scripts/contentScript.js
Normal file
@@ -0,0 +1,5 @@
|
||||
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
if (message.type === "setMilje") {
|
||||
document.body.style.background = `url(${message.milje})`;
|
||||
}
|
||||
});
|
111
scripts/milje.js
111
scripts/milje.js
File diff suppressed because one or more lines are too long
13
scripts/popup.js
Normal file
13
scripts/popup.js
Normal 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);
|
||||
})
|
Reference in New Issue
Block a user