diff --git a/webextensions/background/background.js b/webextensions/background/background.js index b89073e8..695806e7 100644 --- a/webextensions/background/background.js +++ b/webextensions/background/background.js @@ -411,6 +411,7 @@ async function notifyReady() { configs.cachedExternalAddons = addons; } + // migration browser.runtime.onInstalled.addListener(details => { @@ -466,6 +467,37 @@ async function notifyUpdatedFromLegacy() { }); } +function initNotifyFeaturesTab(tab) { + const type = /\?(legacy|installed|updated)/i.test(tab.url) && String(RegExp.$1).toLowerCase(); + + const title = `${browser.i18n.getMessage('extensionName')} ${browser.runtime.getManifest().version}`; + const description = browser.i18n.getMessage( + type == 'legacy' ? + 'message_updatedFromLegacy_description' : + 'message_newFeatures_description' + ); + + browser.tabs.executeScript(tab.id, { + code: ` + document.querySelector('#title').textContent = document.title = ${JSON.stringify(title)}; + document.querySelector('#description').innerHTML = ${JSON.stringify(description)}; + ` + }); +} + +browser.tabs.onUpdated.addListener( + (_tabId, updateInfo, tab) => { + if (updateInfo.status != 'complete') + return; + initNotifyFeaturesTab(tab); + }, + { properties: ['status'], + urls: [browser.extension.getURL(`resources/notify-features.html*`)] } +); +browser.tabs.query({ url: browser.extension.getURL(`resources/notify-features.html*`) }) + .then(tabs => tabs.forEach(initNotifyFeaturesTab)); + + // This section should be removed and define those context-fill icons // statically on manifest.json after Firefox ESR66 (or 67) is released. // See also: https://github.com/piroor/multipletab/issues/215 diff --git a/webextensions/resources/module/.eslintrc.js b/webextensions/resources/module/.eslintrc.js deleted file mode 100644 index d3ba6b09..00000000 --- a/webextensions/resources/module/.eslintrc.js +++ /dev/null @@ -1,15 +0,0 @@ -/* -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ -/*eslint-env commonjs*/ -/*eslint quote-props: ['error', "always"] */ - -'use strict'; - -module.exports = { - 'extends': [ - '../../tools/eslint/for-module.js', - ], -}; diff --git a/webextensions/resources/module/notify-features.js b/webextensions/resources/module/notify-features.js deleted file mode 100644 index ba8db4f3..00000000 --- a/webextensions/resources/module/notify-features.js +++ /dev/null @@ -1,20 +0,0 @@ -/* -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ -'use strict'; - -window.addEventListener('DOMContentLoaded', () => { - const type = /(legacy|installed|updated)/i.test(location.search) && String(RegExp.$1).toLowerCase(); - - const title = `${browser.i18n.getMessage('extensionName')} ${browser.runtime.getManifest().version}`; - const description = browser.i18n.getMessage( - type == 'legacy' ? - 'message_updatedFromLegacy_description' : - 'message_newFeatures_description' - ); - - document.querySelector('#title').textContent = document.title = title; - document.querySelector('#description').innerHTML = description; -}, { once: true }); diff --git a/webextensions/resources/notify-features.html b/webextensions/resources/notify-features.html index 96fa7fbe..0a2729ca 100644 --- a/webextensions/resources/notify-features.html +++ b/webextensions/resources/notify-features.html @@ -2,7 +2,6 @@ -