-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontextMenu.js
More file actions
52 lines (48 loc) · 1.51 KB
/
contextMenu.js
File metadata and controls
52 lines (48 loc) · 1.51 KB
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
const setUpContextMenus = () => {
chrome.contextMenus.removeAll(() => {
const contextMenuHowItWorks = {
id: 'howItWorks',
title: chrome.i18n.getMessage("context_menu_how_it_works"),
contexts: ['action']
}
chrome.contextMenus.create(contextMenuHowItWorks, () => chrome.runtime.lastError)
const contextMenuMyOtherExtyensions = {
id: 'myOtherExtensions',
title: chrome.i18n.getMessage("context_menu_my_other_extensions"),
contexts: ['action']
}
chrome.contextMenus.create(contextMenuMyOtherExtyensions, () => chrome.runtime.lastError)
})
}
chrome.contextMenus.onClicked.addListener((clickData) => {
if (clickData.menuItemId == 'howItWorks') {
const browserLanguage = chrome.i18n.getUILanguage().slice(0, 2)
let guideFileName = 'guide.html'
switch (browserLanguage) {
case 'it':
guideFileName = 'guide-it.html'
break;
case 'es':
guideFileName = 'guide-es.html'
break;
case 'pt':
guideFileName = 'guide-pt.html'
break;
case 'fr':
guideFileName = 'guide-fr.html'
break;
case 'de':
guideFileName = 'guide-de.html'
break;
case 'pl':
guideFileName = 'guide-pl.html'
break;
default:
break;
}
chrome.tabs.create({ url: chrome.runtime.getURL(`${guideFileName}`) })
}
if (clickData.menuItemId == 'myOtherExtensions') {
chrome.tabs.create({ url: 'https://chromewebstore.google.com/search/micpob' })
}
})