-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
51 lines (46 loc) · 1.18 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
browser.contextMenus.create({
id: "download-ig-photo",
title: "Download photo from Instagram",
contexts: ["page"]
});
browser.contextMenus.onClicked.addListener((info) => {
if (info.menuItemId === "download-ig-photo") {
browser.tabs.executeScript({
file: "downloader.js"
}).then((results) => {
onExecuted(results);
}).catch((error) => {
return false;
});
}
});
browser.browserAction.onClicked.addListener(function(tab){
var executing = browser.tabs.executeScript({
file: "downloader-menu.js"
});
executing.then(onExecutedTab, function () {
return false;
});
});
function onExecutedTab(result) {
console.log(result);
var downloading = browser.downloads.download({
url : result[0] + "",
saveAs : true
});
downloading.then(onStartedDownload, function () {
return false;
});
}
function onExecuted(result) {
var downloading = browser.downloads.download({
url : result[0],
saveAs : true
});
downloading.then(onStartedDownload, function () {
return false;
});
}
function onStartedDownload(id) {
return true;
}