Skip to content

Commit

Permalink
Don't close notification tabs on reloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 5, 2020
1 parent 54baf3c commit 3d193f4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 36 deletions.
32 changes: 32 additions & 0 deletions webextensions/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ async function notifyReady() {
configs.cachedExternalAddons = addons;
}


// migration

browser.runtime.onInstalled.addListener(details => {
Expand Down Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions webextensions/resources/module/.eslintrc.js

This file was deleted.

20 changes: 0 additions & 20 deletions webextensions/resources/module/notify-features.js

This file was deleted.

1 change: 0 additions & 1 deletion webextensions/resources/notify-features.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<meta charset="UTF-8">
<link rel="icon" href="./16x16-light.svg">
<title></title>
<script type="module" src="./module/notify-features.js"></script>
<style type="text/css">
body {
background: white;
Expand Down

0 comments on commit 3d193f4

Please sign in to comment.