Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Manifest v3 (per Bug #86) #88

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

// eslint-disable-next-line no-unused-vars
const setBadgeIcon = () => {
chrome.browserAction.setIcon({ path: options.autoCloseTab ? "images/auto_close_16.png" : "images/manual_close_16.png" });
if (environment.isFirefox) browser.browserAction.setBadgeTextColor({ color: "white" });
chrome.action.setIcon({ path: options.autoCloseTab ? "images/auto_close_16.png" : "images/manual_close_16.png" });
if (environment.isFirefox) browser.action.setBadgeTextColor({ color: "white" });
};

const setBadge = async (windowId, activeTabId) => {
Expand Down
14 changes: 7 additions & 7 deletions helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,22 @@ const removeTab = (tabId) => new Promise((resolve, reject) => {

// eslint-disable-next-line no-unused-vars
const setIcon = (details) => new Promise((resolve) => {
chrome.browserAction.setIcon(details, () => {
chrome.action.setIcon(details, () => {
if (chrome.runtime.lastError) console.error("setIcon error:", chrome.runtime.lastError.message);
resolve();
});
});

// eslint-disable-next-line no-unused-vars
const getTabBadgeText = (tabId) => new Promise((resolve) => {
chrome.browserAction.getBadgeText({ tabId: tabId }, badgeText => {
chrome.action.getBadgeText({ tabId: tabId }, badgeText => {
if (chrome.runtime.lastError) console.error("getTabBadgeText error:", chrome.runtime.lastError.message);
resolve(badgeText);
});
});

// eslint-disable-next-line no-unused-vars
const getWindowBadgeText = (windowId) => browser.browserAction.getBadgeText({ windowId: windowId });
const getWindowBadgeText = (windowId) => browser.action.getBadgeText({ windowId: windowId });

// eslint-disable-next-line no-unused-vars
const setTabBadgeText = (tabId, text) => new Promise((resolve) => {
Expand All @@ -167,25 +167,25 @@ const setTabBadgeText = (tabId, text) => new Promise((resolve) => {
resolve();
return;
}
chrome.browserAction.setBadgeText({ tabId: tabId, text: text }, () => {
chrome.action.setBadgeText({ tabId: tabId, text: text }, () => {
if (chrome.runtime.lastError) console.error("setTabBadgeText error:", chrome.runtime.lastError.message);
resolve();
});
});

// eslint-disable-next-line no-unused-vars
const setWindowBadgeText = (windowId, text) => browser.browserAction.setBadgeText({ windowId: windowId, text: text });
const setWindowBadgeText = (windowId, text) => browser.action.setBadgeText({ windowId: windowId, text: text });

// eslint-disable-next-line no-unused-vars
const setTabBadgeBackgroundColor = (tabId, color) => new Promise((resolve) => {
chrome.browserAction.setBadgeBackgroundColor({ tabId: tabId, color: color }, () => {
chrome.action.setBadgeBackgroundColor({ tabId: tabId, color: color }, () => {
if (chrome.runtime.lastError) console.error("setTabBadgeBackgroundColor error:", chrome.runtime.lastError.message);
resolve();
});
});

// eslint-disable-next-line no-unused-vars
const setWindowBadgeBackgroundColor = (windowId, color) => browser.browserAction.setBadgeBackgroundColor({ windowId: windowId, color: color });
const setWindowBadgeBackgroundColor = (windowId, color) => browser.action.setBadgeBackgroundColor({ windowId: windowId, color: color });

// eslint-disable-next-line no-unused-vars
const getStoredOptions = () => Promise.all([
Expand Down
16 changes: 3 additions & 13 deletions manifest-c.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "Duplicate Tabs Closer",
"version": "3.5.3",
"author": "Peuj",
Expand All @@ -9,19 +9,9 @@
"48": "images/auto_close_32.png"
},
"background": {
"scripts": [
"helper.js",
"tabsInfo.js",
"options.js",
"urlUtils.js",
"badge.js",
"worker.js",
"messageListener.js",
"background.js"
]
"service_worker": "scriptImport.js"
},
"browser_action": {
"browser_style": false,
"action": {
"default_icon": {
"16": "images/auto_close_16.png",
"32": "images/auto_close_32.png"
Expand Down
6 changes: 3 additions & 3 deletions manifest-f.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "Duplicate Tabs Closer",
"version": "3.5.3",
"author": "Peuj",
Expand All @@ -11,7 +11,7 @@
"applications": {
"gecko": {
"id": "jid0-RvYT2rGWfM8q5yWxIxAHYAeo5Qg@jetpack",
"strict_min_version": "68.0"
"strict_min_version": "101.0"
}
},
"background": {
Expand Down Expand Up @@ -55,4 +55,4 @@
"browser_style": false,
"open_in_tab": true
}
}
}
7 changes: 4 additions & 3 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,12 @@ const setEnvironment = (storedOptions) => {
};

// eslint-disable-next-line no-unused-vars
const isPanelOptionOpen = () => {
const popups = chrome.extension.getViews({ type: "popup" });
const isPanelOptionOpen = () => {
return false; //override for now, until replacement API comes in
/* const popups = chrome.extension.getViews({ type: "popup" });
if (popups.length) return true;
const tabs = chrome.extension.getViews({ type: "tab" });
return tabs.length > 0;
return tabs.length > 0; */
};

const whiteListToPattern = (whiteList) => {
Expand Down
5 changes: 5 additions & 0 deletions scriptImport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
try {
importScripts("helper.js", "tabsInfo.js", "options.js", "urlUtils.js", "badge.js", "worker.js", "messageListener.js", "background.js");
} catch (e) {
console.error(e);
}