commit 6c5da9538a098aaa953782625164eb196b64631a Author: eclipse Date: Wed Aug 27 23:26:38 2025 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b24cb77 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.code-workspace +tmp.md diff --git a/icons/samoware-multisave-32.png b/icons/samoware-multisave-32.png new file mode 100644 index 0000000..f3b7653 Binary files /dev/null and b/icons/samoware-multisave-32.png differ diff --git a/icons/samoware-multisave-48.png b/icons/samoware-multisave-48.png new file mode 100644 index 0000000..4e82f35 Binary files /dev/null and b/icons/samoware-multisave-48.png differ diff --git a/icons/samoware-multisave-96.png b/icons/samoware-multisave-96.png new file mode 100644 index 0000000..25591e8 Binary files /dev/null and b/icons/samoware-multisave-96.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..7bb5887 --- /dev/null +++ b/manifest.json @@ -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" + ] + } +} diff --git a/samoware-multisave.js b/samoware-multisave.js new file mode 100644 index 0000000..0fe9675 --- /dev/null +++ b/samoware-multisave.js @@ -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); \ No newline at end of file