initial commit
This commit is contained in:
commit
6c5da9538a
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*.code-workspace
|
||||||
|
tmp.md
|
||||||
BIN
icons/samoware-multisave-32.png
Normal file
BIN
icons/samoware-multisave-32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 385 B |
BIN
icons/samoware-multisave-48.png
Normal file
BIN
icons/samoware-multisave-48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 522 B |
BIN
icons/samoware-multisave-96.png
Normal file
BIN
icons/samoware-multisave-96.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 966 B |
28
manifest.json
Normal file
28
manifest.json
Normal 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
47
samoware-multisave.js
Normal 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);
|
||||||
Loading…
Reference in New Issue
Block a user