From 8f04e17d27f179de37365d378689f49aa5df0651 Mon Sep 17 00:00:00 2001 From: tophf Date: Sat, 25 Nov 2017 16:24:07 +0300 Subject: [PATCH] fix #223 - Android compatibility --- background/background.js | 15 +++++++++++---- edit.html | 3 ++- edit/edit.js | 7 +++++-- js/dom.js | 2 +- js/messaging.js | 8 +++++--- js/prefs.js | 3 ++- manage.html | 3 ++- manage/manage.js | 2 +- options.html | 3 ++- popup.html | 3 ++- popup/popup.js | 2 +- 11 files changed, 34 insertions(+), 17 deletions(-) diff --git a/background/background.js b/background/background.js index 47261b53..2a76f8ed 100644 --- a/background/background.js +++ b/background/background.js @@ -30,14 +30,21 @@ chrome.runtime.onMessage.addListener(onRuntimeMessage); listener('styleReplaceAll', data)); } -chrome.contextMenus.onClicked.addListener((info, tab) => - contextMenus[info.menuItemId].click(info, tab)); +if (chrome.contextMenus) { + chrome.contextMenus.onClicked.addListener((info, tab) => + contextMenus[info.menuItemId].click(info, tab)); +} -if ('commands' in chrome) { +if (chrome.commands) { // Not available in Firefox - https://bugzilla.mozilla.org/show_bug.cgi?id=1240350 chrome.commands.onCommand.addListener(command => browserCommands[command]()); } +if (!chrome.browserAction || + !['setIcon', 'setBadgeBackgroundColor', 'setBadgeText'].every(name => chrome.browserAction[name])) { + window.updateIcon = () => {}; +} + // ************************************************************************* // set the default icon displayed after a tab is created until webNavigation kicks in prefs.subscribe(['iconset'], () => updateIcon({id: undefined}, {})); @@ -108,7 +115,7 @@ contextMenus = Object.assign({ } }); -{ +if (chrome.contextMenus) { const createContextMenus = (ids = Object.keys(contextMenus)) => { for (const id of ids) { const item = Object.assign({id}, contextMenus[id]); diff --git a/edit.html b/edit.html index 36393b74..c13e3c75 100644 --- a/edit.html +++ b/edit.html @@ -1,6 +1,7 @@ - + +