initial commit

This commit is contained in:
eclipse 2025-08-27 23:26:38 +02:00
commit 6c5da9538a
6 changed files with 77 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.code-workspace
tmp.md

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 966 B

28
manifest.json Normal file
View File

@ -0,0 +1,28 @@
{
"manifest_version": 2,
"name": "samoware-multisave",
"version": "1.0",
"description": "Whne using the groupware CommuniGate with the web application Samoware, this Browser extension saves all files attached to an openend email to a directory of the user's chhosing, prefixing each entry's filename with the current date. Yes, it's quite specific.",
"icons": {
"48": "icons/samoware-multisave-48.png",
"96": "icons/samoware-multisave-96.png"
},
"permissions": [
"activeTab",
"downloads"
],
"browser_action": {
"default_icon": "icons/samoware-multisave-32.png",
"default_title": "Samoware MultiSave"
},
"background": {
"scripts": [
"samoware-multisave.js"
]
}
}

47
samoware-multisave.js Normal file
View File

@ -0,0 +1,47 @@
function getCurrentDate() {
let today = new Date();
let yyyy = today.getFullYear();
let mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
let dd = String(today.getDate()).padStart(2, '0');
return yyyy + "-" + mm + "-" + dd;
}
function extractFileUrlsAndNames() {
return [];
}
function onStartedDownload(id) {
console.log(`Started downloading: ${id}`);
}
function onFailed(error) {
console.log(`Download failed: ${error}`);
}
function handleButtonClick(event) {
let currentDate = getCurrentDate();
let files = extractFileUrlsAndNames();
for (let i = 0; i < files.length; i++) {
// prefix files[i].filename with currentDate
let prefixedFilename = currentDate + " " + files[i].filename;
let dl = browser.downloads.download({
url: files[i].url,
filename: prefixedFilename,
saveAs: (i == 0) // raise a path chooser dialog for the first file only; all later files will (hopefully!) be saved to the same folder
}).then(onStartedDownload, onFailed);
}
}
// add listener for the extension button
browser.browserAction.onClicked.addListener(handleButtonClick);