Skip to content

Commit ee328c5

Browse files
committed
v3.0.1:
* Icons in the context menu if the browser supports it (Firefox 56+) (fixes #8)
1 parent 45d4804 commit ee328c5

File tree

11 files changed

+14
-5
lines changed

11 files changed

+14
-5
lines changed

background.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Set up context menu for images
22
function createContextMenu(options) {
33
const title = chrome.i18n.getMessage("contextMenuTitle");
4-
4+
55
/* If there is only one search provider, do not create a submenu */
66
if (options.searchProviders.length == 1) {
77
chrome.contextMenus.create({
@@ -18,13 +18,22 @@ function createContextMenu(options) {
1818
title: title,
1919
contexts: ["image"]
2020
});
21-
for (i = 0; i < options.searchProviders.length; i++) {
22-
chrome.contextMenus.create({
21+
for (i = 0; i < options.searchProviders.length; i++) {
22+
var contextMenuOptions = {
2323
parentId: "Image-Reverse-Search",
2424
id: options.searchProviders[i],
25+
icons: {
26+
64: "icons/" + options.searchProviders[i] + ".png"
27+
},
2528
title: searchProviderNames[options.searchProviders[i]],
2629
contexts: ["image"]
27-
});
30+
}
31+
try {
32+
chrome.contextMenus.create(contextMenuOptions);
33+
} catch(exception) { // when the browser doesn't support icons for submenus
34+
delete contextMenuOptions.icons
35+
chrome.contextMenus.create(contextMenuOptions);
36+
}
2837
}
2938
}
3039

icons/baidu.png

914 Bytes
Loading

icons/bing.png

576 Bytes
Loading

icons/google.png

1.58 KB
Loading

icons/iqdb.png

4.34 KB
Loading

icons/other.png

1.01 KB
Loading

icons/saucenao.png

601 Bytes
Loading

icons/tineye.png

2.94 KB
Loading

icons/yandex.png

661 Bytes
Loading

icons/yandexru.png

665 Bytes
Loading

0 commit comments

Comments
 (0)