-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate-menus.js
173 lines (144 loc) · 4.55 KB
/
create-menus.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// This file is only used to create the menu entries
const reload_periods = [
-1, "Don't reload",
5, "Every 5 secs",
15, "Every 15 secs",
60, "Every minute",
300, "Every 5 minutes",
900, "Every 15 minutes",
3600, "Every hour",
14400, "Every 4 hours",
-2, "Custom interval"
]
const num_periods = reload_periods.length;
async function createMenu()
{
const canUseTabContext = (typeof browser.menus.refresh === "function");
const menuContexts = canUseTabContext ? ["all", "tab"] : ["all"];
let promises = [];
promises.push(browser.menus.create({
id: "reloadmatic-mnu-root",
title: "Reload",
contexts: menuContexts
}));
for (let i = 0; i < num_periods/2; i++) {
promises.push(browser.menus.create({
id: `reloadmatic-mnu-period-${reload_periods[i*2]}`,
title: reload_periods[i*2+1],
type: "radio",
parentId: "reloadmatic-mnu-root"
}));
}
promises.push(browser.menus.create({
id: "reloadmatic-mnu-separator-1",
type: "separator",
parentId: "reloadmatic-mnu-root"
}));
/*********************************/
/* OPTIONS */
/*********************************/
promises.push(browser.menus.create({
id: "reloadmatic-mnu-remember",
title: "Remember page",
type: "checkbox",
parentId: "reloadmatic-mnu-root"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-randomize",
title: "Randomize",
type: "checkbox",
parentId: "reloadmatic-mnu-root"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-unsuccessful",
title: "Only if unsuccessful",
type: "checkbox",
parentId: "reloadmatic-mnu-root"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-smart",
title: "Smart timing",
type: "checkbox",
parentId: "reloadmatic-mnu-root"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-sticky",
title: "Sticky reload",
type: "checkbox",
parentId: "reloadmatic-mnu-root"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-disable-cache",
title: "Disable cache",
type: "checkbox",
parentId: "reloadmatic-mnu-root"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-fix-url",
title: "Fix URL",
type: "checkbox",
parentId: "reloadmatic-mnu-root"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-separator-2",
type: "separator",
parentId: "reloadmatic-mnu-root"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-reload",
title: "Reload now",
parentId: "reloadmatic-mnu-root"
}));
/*********************************/
/* ALL TABS */
/*********************************/
promises.push(browser.menus.create({
id: "reloadmatic-mnu-alltabs",
title: "All tabs",
parentId: "reloadmatic-mnu-root"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-enable-all",
title: "Set to all",
parentId: "reloadmatic-mnu-alltabs"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-disable-all",
title: "Disable on all",
parentId: "reloadmatic-mnu-alltabs"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-reload-all",
title: "Reload all now",
parentId: "reloadmatic-mnu-alltabs"
}));
/*********************************/
/* ABOUT */
/*********************************/
promises.push(browser.menus.create({
id: "reloadmatic-mnu-about",
title: "About",
parentId: "reloadmatic-mnu-root"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-settings",
title: "Settings",
parentId: "reloadmatic-mnu-about"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-faq",
title: "F.A.Q.",
parentId: "reloadmatic-mnu-about"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-amo",
title: "AMO Site",
parentId: "reloadmatic-mnu-about"
}));
promises.push(browser.menus.create({
id: "reloadmatic-mnu-support",
title: "Issues and requests",
parentId: "reloadmatic-mnu-about"
}));
return Promise.all(promises);
}