-
Notifications
You must be signed in to change notification settings - Fork 0
/
context_menu.js
45 lines (43 loc) · 1.43 KB
/
context_menu.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
function addonStartup() {
browser.menus.create({
"id": "earliest_capture",
"title": "Travel to the earliest archived version of this page",
"contexts": ["all"]
});
browser.menus.create({
"id": "capture_calendar",
"title": "Pick a date to travel to",
"contexts": ["all"]
});
browser.menus.create({
"id": "latest_capture",
"title": "Travel to the latest archived version of this page",
"contexts": ["all"]
});
browser.menus.create({
"id": "capture_page",
"title": "Freeze this page in time",
"contexts": ["all"]
});
}
browser.menus.onClicked.addListener((info, tab) => {
if (info.menuItemId === "earliest_capture") {
browser.tabs.create({
url: "https://web.archive.org/web/1995/" + info.pageUrl
});
} else if (info.menuItemId === "capture_calendar") {
browser.tabs.create({
url: "https://web.archive.org/web/*/" + info.pageUrl
});
} else if (info.menuItemId === "latest_capture") {
browser.tabs.create({
url: "https://web.archive.org/web/" + info.pageUrl
});
} else if (info.menuItemId === "capture_page") {
browser.tabs.create({
url: "https://web.archive.org/save/" + info.pageUrl
});
}
});
browser.runtime.onInstalled.addListener((addonStartup));
browser.runtime.onStartup.addListener((addonStartup));