Recheck on initial install
This commit is contained in:
parent
bd44f041d5
commit
b506724b97
|
@ -162,23 +162,6 @@ navigatorUtil.onUrlChange(({tabId, frameId, transitionQualifiers}, type) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// *************************************************************************
|
|
||||||
chrome.runtime.onInstalled.addListener(({reason}) => {
|
|
||||||
// save install type: "admin", "development", "normal", "sideload" or "other"
|
|
||||||
// "normal" = addon installed from webstore
|
|
||||||
chrome.management.getSelf(info => {
|
|
||||||
localStorage.installType = info.installType;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (reason !== 'update') return;
|
|
||||||
// translations may change
|
|
||||||
localStorage.L10N = JSON.stringify({
|
|
||||||
browserUIlanguage: chrome.i18n.getUILanguage(),
|
|
||||||
});
|
|
||||||
// themes may change
|
|
||||||
delete localStorage.codeMirrorThemes;
|
|
||||||
});
|
|
||||||
|
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
// browser commands
|
// browser commands
|
||||||
browserCommands = {
|
browserCommands = {
|
||||||
|
@ -210,7 +193,7 @@ contextMenus = {
|
||||||
click: browserCommands.openOptions,
|
click: browserCommands.openOptions,
|
||||||
},
|
},
|
||||||
'reload': {
|
'reload': {
|
||||||
presentIf: () => localStorage.installType !== 'normal',
|
presentIf: () => localStorage.installType === 'development',
|
||||||
title: 'reload',
|
title: 'reload',
|
||||||
click: browserCommands.reload,
|
click: browserCommands.reload,
|
||||||
},
|
},
|
||||||
|
@ -226,7 +209,6 @@ contextMenus = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (chrome.contextMenus) {
|
|
||||||
const createContextMenus = ids => {
|
const createContextMenus = ids => {
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
let item = contextMenus[id];
|
let item = contextMenus[id];
|
||||||
|
@ -248,6 +230,7 @@ if (chrome.contextMenus) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (chrome.contextMenus) {
|
||||||
// circumvent the bug with disabling check marks in Chrome 62-64
|
// circumvent the bug with disabling check marks in Chrome 62-64
|
||||||
const toggleCheckmark = CHROME >= 3172 && CHROME <= 3288 ?
|
const toggleCheckmark = CHROME >= 3172 && CHROME <= 3288 ?
|
||||||
(id => chrome.contextMenus.remove(id, () => createContextMenus([id]) + ignoreChromeError())) :
|
(id => chrome.contextMenus.remove(id, () => createContextMenus([id]) + ignoreChromeError())) :
|
||||||
|
@ -267,6 +250,26 @@ if (chrome.contextMenus) {
|
||||||
createContextMenus(keys);
|
createContextMenus(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// *************************************************************************
|
||||||
|
chrome.runtime.onInstalled.addListener(({reason}) => {
|
||||||
|
// save install type: "admin", "development", "normal", "sideload" or "other"
|
||||||
|
// "normal" = addon installed from webstore
|
||||||
|
chrome.management.getSelf(info => {
|
||||||
|
localStorage.installType = info.installType;
|
||||||
|
if (reason === 'install' && info.installType === 'development' && chrome.contextMenus) {
|
||||||
|
createContextMenus(['reload']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (reason !== 'update') return;
|
||||||
|
// translations may change
|
||||||
|
localStorage.L10N = JSON.stringify({
|
||||||
|
browserUIlanguage: chrome.i18n.getUILanguage(),
|
||||||
|
});
|
||||||
|
// themes may change
|
||||||
|
delete localStorage.codeMirrorThemes;
|
||||||
|
});
|
||||||
|
|
||||||
// reinject content scripts when the extension is reloaded/updated. Firefox
|
// reinject content scripts when the extension is reloaded/updated. Firefox
|
||||||
// would handle this automatically.
|
// would handle this automatically.
|
||||||
if (!FIREFOX) {
|
if (!FIREFOX) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user