Skip to content

Commit

Permalink
check if contextMenus is available to make it possible to run in mobi…
Browse files Browse the repository at this point in the history
…le firefox browser.
  • Loading branch information
mdnsk committed Jan 17, 2018
1 parent fd24169 commit 3557097
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Leo Translate",
"version": "1.8.6",
"version": "1.8.7",

"description": "Translate words on the internet pages using LinguaLeo API and add words to the LinguaLeo Dictionary.",

Expand Down
32 changes: 17 additions & 15 deletions src/entry/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@ import {
import { removeHtmlTags } from '../helpers';

// Create context item
chrome.contextMenus.create({
id: 'leo-translate',
title: 'Translate with Leo',
contexts: ['selection'],
onclick: (info, tab) => {
chrome.tabs.sendMessage(tab.id, {
id: CONTENT_OPEN_POPUP,
text: info.selectionText,
context: ''
});
},
icons: {
'16': '../icons/icon.svg'
}
});
if (chrome.contextMenus !== undefined) {
chrome.contextMenus.create({
id: 'leo-translate',
title: 'Translate with Leo',
contexts: ['selection'],
onclick: (info, tab) => {
chrome.tabs.sendMessage(tab.id, {
id: CONTENT_OPEN_POPUP,
text: info.selectionText,
context: ''
});
},
icons: {
'16': '../icons/icon.svg'
}
});
}

// Listen for message to show in system notification
chrome.runtime.onMessage.addListener((message, sender) => {
Expand Down

0 comments on commit 3557097

Please sign in to comment.