reset L10N cache on update
This commit is contained in:
parent
736302962c
commit
3628564961
|
@ -48,33 +48,29 @@ if ('commands' in chrome) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
// Open FAQs page once after installation to guide new users.
|
{
|
||||||
// Do not display it in development mode.
|
const onInstall = ({reason}) => {
|
||||||
if (chrome.runtime.getManifest().update_url) {
|
chrome.runtime.onInstalled.removeListener(onInstall);
|
||||||
const openHomepageOnInstall = ({reason}) => {
|
const manifest = chrome.runtime.getManifest();
|
||||||
chrome.runtime.onInstalled.removeListener(openHomepageOnInstall);
|
// Open FAQs page once after installation to guide new users.
|
||||||
if (reason == 'install') {
|
// Do not display it in development mode.
|
||||||
const version = chrome.runtime.getManifest().version;
|
if (reason == 'install' && manifest.update_url) {
|
||||||
setTimeout(openURL, 100, {
|
setTimeout(openURL, 100, {
|
||||||
url: `http://add0n.com/stylus.html?version=${version}&type=install`
|
url: `http://add0n.com/stylus.html?version=${manifest.version}&type=install`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// reset L10N cache on UI language change or update
|
||||||
|
const {browserUIlanguage} = tryJSONparse(localStorage.L10N) || {};
|
||||||
|
const UIlang = chrome.i18n.getUILanguage();
|
||||||
|
if (reason == 'update' || browserUIlanguage != UIlang) {
|
||||||
|
localStorage.L10N = JSON.stringify({
|
||||||
|
browserUIlanguage: UIlang,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// bind for 60 seconds max and auto-unbind if it's a normal run
|
// bind for 60 seconds max and auto-unbind if it's a normal run
|
||||||
chrome.runtime.onInstalled.addListener(openHomepageOnInstall);
|
chrome.runtime.onInstalled.addListener(onInstall);
|
||||||
setTimeout(openHomepageOnInstall, 60e3, {reason: 'unbindme'});
|
setTimeout(onInstall, 60e3, {reason: 'unbindme'});
|
||||||
}
|
|
||||||
|
|
||||||
// *************************************************************************
|
|
||||||
// reset L10N cache on UI language change
|
|
||||||
{
|
|
||||||
const {browserUIlanguage} = tryJSONparse(localStorage.L10N) || {};
|
|
||||||
const UIlang = chrome.i18n.getUILanguage();
|
|
||||||
if (browserUIlanguage != UIlang) {
|
|
||||||
localStorage.L10N = JSON.stringify({
|
|
||||||
browserUIlanguage: UIlang,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
|
|
Loading…
Reference in New Issue
Block a user