mirror of
https://codeberg.org/icewind/originfox.git
synced 2026-06-03 10:14:08 +02:00
initial version
This commit is contained in:
parent
907eab9601
commit
b6ac4f9f4b
5 changed files with 375 additions and 5 deletions
29
addon/background.js
Normal file
29
addon/background.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
function onResponse(response) {
|
||||
if (!response.success) {
|
||||
console.error("Error setting attributes");
|
||||
}
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
function handleChanged(delta) {
|
||||
if (delta.state && delta.state.current === "complete") {
|
||||
browser.downloads
|
||||
.search({
|
||||
id: delta.id,
|
||||
}).then(downloads => {
|
||||
let download = downloads[0];
|
||||
browser.runtime.sendNativeMessage("originfox", {
|
||||
path: download.filename,
|
||||
origin: download.url,
|
||||
referrer: download.referrer,
|
||||
}).then(onResponse, onError);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
browser.downloads.onChanged.addListener(handleChanged);
|
||||
19
addon/manifest.json
Normal file
19
addon/manifest.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"description": "Save download origin data to extended attributes",
|
||||
"manifest_version": 2,
|
||||
"name": "originfox",
|
||||
"version": "1.0",
|
||||
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
"id": "originfox@icewind.nl",
|
||||
"strict_min_version": "50.0"
|
||||
}
|
||||
},
|
||||
|
||||
"background": {
|
||||
"scripts": ["background.js"]
|
||||
},
|
||||
|
||||
"permissions": ["nativeMessaging", "downloads"]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue