|
|
@@ -37,14 +37,8 @@ singlefile.ui.button = (() => {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- browser.tabs.onActivated.addListener(async activeInfo => {
|
|
|
- const tab = await browser.tabs.get(activeInfo.tabId);
|
|
|
- await onTabActivated(tab);
|
|
|
- });
|
|
|
- browser.tabs.onCreated.addListener(async tab => {
|
|
|
- await refreshProperty(tab.id, "setBadgeBackgroundColor", { color: DEFAULT_COLOR });
|
|
|
- await onTabActivated(tab);
|
|
|
- });
|
|
|
+ browser.tabs.onActivated.addListener(activeInfo => onTabActivated(activeInfo));
|
|
|
+ browser.tabs.onCreated.addListener(tab => onTabCreated(tab));
|
|
|
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => onTabActivated(tab));
|
|
|
browser.runtime.onMessage.addListener((request, sender) => {
|
|
|
if (request.processReset) {
|
|
|
@@ -82,6 +76,16 @@ singlefile.ui.button = (() => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ async function onTabActivated(activeInfo) {
|
|
|
+ const tab = await browser.tabs.get(activeInfo.tabId);
|
|
|
+ onActivated(tab);
|
|
|
+ }
|
|
|
+
|
|
|
+ async function onTabCreated(tab) {
|
|
|
+ await refreshProperty(tab.id, "setBadgeBackgroundColor", { color: DEFAULT_COLOR });
|
|
|
+ onActivated(tab);
|
|
|
+ }
|
|
|
+
|
|
|
function onReset(tabId) {
|
|
|
refresh(tabId, getProperties({}, "", DEFAULT_COLOR, DEFAULT_TITLE));
|
|
|
}
|
|
|
@@ -112,7 +116,7 @@ singlefile.ui.button = (() => {
|
|
|
refresh(tabId, getProperties(options, "", [4, 229, 36, 255], browser.i18n.getMessage("buttonSaveProgressTooltip") + (progress * 5) + "%", path, [128, 128, 128, 255]));
|
|
|
}
|
|
|
|
|
|
- async function onTabActivated(tab) {
|
|
|
+ async function onActivated(tab) {
|
|
|
const autoSave = await singlefile.autosave.enabled(tab.id);
|
|
|
const properties = getCurrentProperties(tab.id, { autoSave });
|
|
|
await refresh(tab.id, properties, true);
|