diff --git a/background.js b/background.js index 16c39e8..fbc60d3 100644 --- a/background.js +++ b/background.js @@ -1,4 +1,4 @@ -const browser = chrome || browser +const browser = globalThis.browser || chrome const tabQuery = (options, params = {}) => new Promise(res => { if (!options.countPinnedTabs) params.pinned = false // only non-pinned tabs @@ -15,7 +15,7 @@ const totalRemaining = options => const updateBadge = options => { if (!options.displayBadge) { - browser.browserAction.setBadgeText({ text: "" }) + browser.action.setBadgeText({ text: "" }) return; } @@ -23,7 +23,7 @@ const updateBadge = options => { .then(remaining => { // console.log(remaining) // remaining = [remainingInWindow, remainingInTotal] - browser.browserAction.setBadgeText({ + browser.action.setBadgeText({ text: Math.min(...remaining).toString() }) }) @@ -104,7 +104,12 @@ const displayAlert = (options, place) => new Promise((res, rej) => { /{\s*(\S+)\s*}/g, replacer ) - alert(renderedMessage); + chrome.notifications.create('tab-limiter-alert', { + type: 'basic', + iconUrl: 'icons/48.png', + title: 'Tab Limiter', + message: renderedMessage + }, () => res(true)); }) let tabCount = -1 diff --git a/manifest.json b/manifest.json index 5058569..64ad200 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "Tab Limiter", "description": "Limit the number of open tabs – in total and per window", - "version": "0.3.0", + "version": "0.4.0", "author": "Matthias Vogt", "homepage_url": "https://github.com/matthias-vogt/tab-limiter", @@ -10,7 +10,7 @@ "128": "icons/128.png" }, - "browser_action": { + "action": { "default_icon": { "48": "icons/48.png", "128": "icons/128.png" @@ -20,13 +20,12 @@ }, "options_page": "options.html", "background": { - "scripts": [ - "background.js" - ] + "service_worker": "background.js" }, "permissions": [ - "storage" + "storage", + "notifications" ], - "manifest_version": 2 + "manifest_version": 3 } diff --git a/options.html b/options.html index da39684..c96fad3 100644 --- a/options.html +++ b/options.html @@ -5,7 +5,6 @@ -
@@ -56,4 +55,5 @@