From f74eeb575942cfd769dd8ecc93ddfb37c36f4ce9 Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Mon, 10 Aug 2020 23:46:37 +0300 Subject: [PATCH] [v1.7.3] Firefox compability patch (#32) - Added Firefox support (#28) - Updated settings defaults - Updated `about:` protocol behavior - Fixed collections header becoming the old one on a tab removing - Added VS Code debugging config - Removed trailing whitespaces --- .vscode/launch.json | 13 ++++++++++++ CONTRIBUTING.md | 14 ++++++------- README.md | 44 ++++++++++++++++++++++----------------- TabsAside.html | 6 ++++-- _locales/en/messages.json | 2 +- _locales/ru/messages.json | 2 +- css/style.css | 19 ++++++++++------- css/style.dark.css | 8 ++++--- css/style.generic.css | 20 +++++++++++------- js/aside-script.js | 36 +++++++++++++++++--------------- js/background.js | 38 +++++++++++++++++++-------------- manifest.json | 44 ++++++++++++++++++++++++++++++++++----- 12 files changed, 160 insertions(+), 86 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3d73cd3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": + [ + { + "name": "Debug", + "type": "firefox", + "request": "launch", + "reAttach": true, + "addonPath": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f52250d..8aefed5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,15 +35,15 @@ Have a question? Rather than opening an issue, please ask me directly on opensou ## Providing Feedback Your comments and feedback are welcome. -You can leave your feedbak on feedback@xfox111.net or do it on [Microsoft Edge Add-ons Webstore](https://microsoftedge.microsoft.com/addons/detail/tabs-aside/kmnblllmalkiapkfknnlpobmjjdnlhnd) or [Chrome Webstore](https://chrome.google.com/webstore/detail/tabs-aside/mgmjbodjgijnebfgohlnjkegdpbdjgin) +You can leave your feedbak on feedback@xfox111.net or do it on [Microsoft Edge Add-ons Webstore](https://microsoftedge.microsoft.com/addons/detail/tabs-aside/kmnblllmalkiapkfknnlpobmjjdnlhnd), [Chrome Extensions Webstore](https://chrome.google.com/webstore/detail/tabs-aside/mgmjbodjgijnebfgohlnjkegdpbdjgin) or [Mozilla Add-ons Webstore](https://addons.mozilla.org/firefox/addon/ms-edge-tabs-aside/) ## Reporting Issues Have you identified a reproducible problem in the extension? Have a feature request? I'd like to hear it! Here's how you can make reporting your issue as effective as possible. ### Look For an Existing Issue -Before you create a new issue, please do a search in [open issues](https://github.com/xfox111/ChromiumTabsAside/issues) to see if the issue or feature request has already been filed. +Before you create a new issue, please do a search in [open issues](https://github.com/xfox111/TabsAsideExtension/issues) to see if the issue or feature request has already been filed. -Be sure to scan through the [feature requests](https://github.com/XFox111/ChromiumTabsAside/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement). +Be sure to scan through the [feature requests](https://github.com/XFox111/TabsAsideExtension/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement). If you find your issue already exists, make relevant comments and add your [reaction](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). Use a reaction in place of a "+1" comment: @@ -83,7 +83,7 @@ If you are interested in writing code to fix issues or implement new awesome fea ### Deploy test version on your browser 1. Clone repository to local storage using [Git](https://guides.github.com/introduction/git-handbook/) ``` - git clone https://github.com/xfox111/ChromiumTabsAside.git + git clone https://github.com/xfox111/TabsAsideExtension.git ``` 2. Enable Developers mode on your browser extensions page 3. Click "Load unpacked" button and navigate to the extension root folder (contains `manifest.json`) @@ -135,14 +135,14 @@ Use "double quotes" wherever it's possible } ``` - Put spaces between operators and before braces in methods declarations, conditionals and loops - - Wrong: + - Wrong: - `y=k*x+b` - `function FunctionName()` - Correct: - `y = k * x + b` - `function FunctionName ()` - Use ternary conditionals wherever it's possible - - Wrong: + - Wrong: ``` var s; if (condition) @@ -175,7 +175,7 @@ Use "double quotes" wherever it's possible ``` ### Finding an issue to work on -Check out the [full issues list](https://github.com/XFox111/ChromiumTabsAside/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue) for a list of all potential areas for contributions. **Note** that just because an issue exists in the repository does not mean we will accept a contribution. There are several reasons we may not accept a pull request like: +Check out the [full issues list](https://github.com/XFox111/TabsAsideExtension/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue) for a list of all potential areas for contributions. **Note** that just because an issue exists in the repository does not mean we will accept a contribution. There are several reasons we may not accept a pull request like: - Performance - One of Tabs Aside core values is to deliver a lightweight extension, that means it should perform well in both real and test environments. - User experience - Since we want to deliver a lightweight extension, the UX should feel lightweight as well and not be cluttered. Most changes to the UI should go through the issue owner and project owner (@XFox111). diff --git a/README.md b/README.md index 081a6ba..4ab5122 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,45 @@ -# Tabs aside for Google Chrome +# Tabs aside -[![Chrome Web Store](https://img.shields.io/chrome-web-store/users/mgmjbodjgijnebfgohlnjkegdpbdjgin?label=Chrome%20Web%20Store%20downloads)](https://chrome.google.com/webstore/detail/tabs-aside/mgmjbodjgijnebfgohlnjkegdpbdjgin) +[![Chrome Web Store](https://img.shields.io/chrome-web-store/users/mgmjbodjgijnebfgohlnjkegdpbdjgin?label=Chrome%20Webstore%20downloads)](https://chrome.google.com/webstore/detail/tabs-aside/mgmjbodjgijnebfgohlnjkegdpbdjgin) [![Chrome Web Store](https://img.shields.io/chrome-web-store/rating/mgmjbodjgijnebfgohlnjkegdpbdjgin)](https://chrome.google.com/webstore/detail/tabs-aside/mgmjbodjgijnebfgohlnjkegdpbdjgin) -[![GitHub release (latest by date)](https://img.shields.io/github/v/release/xfox111/chromiumtabsaside)](https://github.com/xfox111/chromiumtabsaside/releases/latest) +[![GitHub release (latest by date)](https://img.shields.io/github/v/release/xfox111/TabsAsideExtension)](https://github.com/xfox111/TabsAsideExtension/releases/latest) -[![GitHub issues](https://img.shields.io/github/issues/xfox111/chromiumtabsaside)](https://github.com/xfox111/ChromiumTabsAside/issues) -[![GitHub last commit](https://img.shields.io/github/last-commit/xfox111/chromiumtabsaside)](https://github.com/xfox111/ChromiumTabsAside/commits/master) -[![GitHub repo size](https://img.shields.io/github/repo-size/xfox111/chromiumtabsaside?label=repo%20size)](https://github.com/xfox111/ChromiumTabsAside) -[![MIT License](https://img.shields.io/github/license/xfox111/chromiumtabsaside)](https://opensource.org/licenses/MIT) +[![Mozilla Add-on](https://img.shields.io/amo/users/ms-edge-tabs-aside?label=Firefox%20Webstore%20downloads)](https://addons.mozilla.org/firefox/addon/ms-edge-tabs-aside/) +[![Mozilla Add-on](https://img.shields.io/amo/rating/ms-edge-tabs-aside)](https://addons.mozilla.org/firefox/addon/ms-edge-tabs-aside/) +[![Mozilla Add-on](https://img.shields.io/amo/dw/ms-edge-tabs-aside)](https://addons.mozilla.org/firefox/addon/ms-edge-tabs-aside/) + +[![GitHub issues](https://img.shields.io/github/issues/xfox111/TabsAsideExtension)](https://github.com/xfox111/TabsAsideExtension/issues) +[![GitHub last commit](https://img.shields.io/github/last-commit/xfox111/TabsAsideExtension)](https://github.com/xfox111/TabsAsideExtension/commits/master) +[![GitHub repo size](https://img.shields.io/github/repo-size/xfox111/TabsAsideExtension?label=repo%20size)](https://github.com/xfox111/TabsAsideExtension) +[![MIT License](https://img.shields.io/github/license/xfox111/TabsAsideExtension)](https://opensource.org/licenses/MIT) [![Twitter Follow](https://img.shields.io/twitter/follow/xfox111?style=social)](https://twitter.com/xfox111) [![GitHub followers](https://img.shields.io/github/followers/xfox111?label=Follow%20@xfox111&style=social)](https://github.com/xfox111) [![Buy Me a Coffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-%40xfox111-orange)](https://buymeacoffee.com/xfox111) -![Tabs aside](https://xfox111.net/images/TabsAside.png) +![Tabs aside](https://xfox111.net/y7xk3z) If you’re like me, you often find yourself with a bunch of open tabs. You’d like to get those tabs out of the way sometimes, but they’re maybe not worth saving as actual bookmarks. In the Edge browser, Microsoft has introduced a new feature called "Tabs aside" (or Tab groups) which lets you set tabs aside in a sort of temporary workspace so that you can call them back up later. -Unfortunately, in new Chromium-based Microsoft Edge, the devs decided not to implement this must-have-feature. So I've decided to create a browser extension which replicates this awesome feature in Chromium-based browsers +Unfortunately, in new Chromium-based Microsoft Edge, the devs decided not to implement this must-have-feature. So I've decided to create a browser extension which replicates this awesome feature ## Features - Familiar UI inherited from legacy Microsoft Edge with some improvements - Auto Dark mode - Now you can restore one tab from collection without removing - Now you can choose if you want to load restored tabs only when you're navigating onto them +- **Now available for Firefox!** ## Download - [Google Chrome Webstore](https://chrome.google.com/webstore/detail/tabs-aside/mgmjbodjgijnebfgohlnjkegdpbdjgin) - [Microsoft Edge Add-ons Webstore](https://microsoftedge.microsoft.com/addons/detail/kmnblllmalkiapkfknnlpobmjjdnlhnd) -- [GitHub Releases](https://github.com/xfox111/chromiumtabsaside/releases/latest) +- [Firefox Add-ons](https://addons.mozilla.org/firefox/addon/ms-edge-tabs-aside/) +- [GitHub Releases](https://github.com/xfox111/TabsAsideExtension/releases/latest) ## Project roadmap -You can go to the project's [roadmap kanban board](https://github.com/XFox111/ChromiumTabsAside/projects/1) and see what have we planned and watch our progress in realtime +You can go to the project's [roadmap kanban board](https://github.com/XFox111/TabsAsideExtension/projects/1) and see what have we planned and watch our progress in realtime ## Contributing There are many ways in which you can participate in the project, for example: @@ -41,16 +47,16 @@ There are many ways in which you can participate in the project, for example: - Review [source code changes](https://github.com/xfox111/gutschedule/pulls) - Review documentation and make pull requests for anything from typos to new content -If you are interested in fixing issues and contributing directly to the code base, please see the [Contribution Guidelines](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md), which covers the following: -- [How to deploy the extension on your browser](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#deploy-test-version-on-your-browser) -- [The development workflow](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#development-workflow), including debugging and running tests -- [Coding guidelines](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#coding-guidelines) -- [Submitting pull requests](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#submitting-pull-requests) -- [Finding an issue to work on](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#finding-an-issue-to-work-on) -- [Contributing to translations](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#contributing-to-translations) +If you are interested in fixing issues and contributing directly to the code base, please see the [Contribution Guidelines](https://github.com/XFox111/TabsAsideExtension/blob/master/CONTRIBUTING.md), which covers the following: +- [How to deploy the extension on your browser](https://github.com/XFox111/TabsAsideExtension/blob/master/CONTRIBUTING.md#deploy-test-version-on-your-browser) +- [The development workflow](https://github.com/XFox111/TabsAsideExtension/blob/master/CONTRIBUTING.md#development-workflow), including debugging and running tests +- [Coding guidelines](https://github.com/XFox111/TabsAsideExtension/blob/master/CONTRIBUTING.md#coding-guidelines) +- [Submitting pull requests](https://github.com/XFox111/TabsAsideExtension/blob/master/CONTRIBUTING.md#submitting-pull-requests) +- [Finding an issue to work on](https://github.com/XFox111/TabsAsideExtension/blob/master/CONTRIBUTING.md#finding-an-issue-to-work-on) +- [Contributing to translations](https://github.com/XFox111/TabsAsideExtension/blob/master/CONTRIBUTING.md#contributing-to-translations) ## Code of Conduct -This project has adopted the Contributor Covenant. For more information see the [Code of Conduct](https://github.com/XFox111/ChromiumTabsAside/blob/master/CODE_OF_CONDUCT.md) +This project has adopted the Contributor Covenant. For more information see the [Code of Conduct](https://github.com/XFox111/TabsAsideExtension/blob/master/CODE_OF_CONDUCT.md) ## Copyrights > ©2020 Michael "XFox" Gordeev diff --git a/TabsAside.html b/TabsAside.html index 542fed5..b98aa39 100644 --- a/TabsAside.html +++ b/TabsAside.html @@ -8,6 +8,8 @@ + + @@ -33,8 +35,8 @@


- - + +
diff --git a/_locales/en/messages.json b/_locales/en/messages.json index f3f95d8..9fac0f3 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -6,7 +6,7 @@ }, "description": { - "message": "Classic Microsoft Edge \"Tabs Aside\" feature for Chromium browsers", + "message": "Classic Microsoft Edge \"Tabs Aside\" feature", "description": "Extension description" }, "author": diff --git a/_locales/ru/messages.json b/_locales/ru/messages.json index b3ca9a9..b42bb5b 100644 --- a/_locales/ru/messages.json +++ b/_locales/ru/messages.json @@ -6,7 +6,7 @@ }, "description": { - "message": "Функиця классического Microsoft Edge на браузерах Chromium", + "message": "Функиця отложенных вкладок классического Microsoft Edge", "description": "Extension description" }, "author": diff --git a/css/style.css b/css/style.css index 7262e8f..cceddf5 100644 --- a/css/style.css +++ b/css/style.css @@ -21,7 +21,7 @@ overflow: hidden; display: grid; grid-template-rows: auto 1fr; - + width: 100%; min-width: 500px; @@ -68,7 +68,7 @@ font-weight: 500; font-size: 15pt; } - + .tabsAside.pane > header > div > nav { top: 45px; @@ -102,7 +102,8 @@ background-repeat: no-repeat; background-size: 16px; background-position: center; - background-image: url("chrome-extension://__MSG_@@extension_id__/icons/arrowRight.svg"); + background-image: url("chrome-extension://__MSG_@@extension_id__/icons/arrowRight.svg"), + url("moz-extension://__MSG_@@extension_id__/icons/arrowRight.svg"); margin: 2px; } @@ -160,14 +161,14 @@ color: gray; visibility: visible !important; } - + .collectionSet > .header > h4 { margin: 0px; visibility: visible !important; font-weight: 500; } - + .collectionSet > .header > a { font-size: 11pt; @@ -195,7 +196,7 @@ .collectionSet > .set:hover::-webkit-scrollbar-thumb { visibility: visible; - } + } .collectionSet > .set > div { @@ -204,7 +205,8 @@ margin: 5px; background-color: #c2c2c2; - background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_thumbnail.png"); + background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_thumbnail.png"), + url("chrome-extension://__MSG_@@extension_id__/images/tab_thumbnail.png"); background-size: cover; background-position-x: center; @@ -248,7 +250,8 @@ height: 20px; margin: 8px; - background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_icon.png"); + background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_icon.png"), + url("moz-extension://__MSG_@@extension_id__/images/tab_icon.png"); background-size: 20px; } diff --git a/css/style.dark.css b/css/style.dark.css index 42fca91..5be3d7d 100644 --- a/css/style.dark.css +++ b/css/style.dark.css @@ -4,7 +4,7 @@ } .tabsAside[darkmode] .pane -{ +{ background-color: #333333; color: white; } @@ -70,7 +70,8 @@ .tabsAside[darkmode] .pane .collectionSet > .set > div { background-color: #0c0c0c; - background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_thumbnail_dark.png"); + background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_thumbnail_dark.png"), + url("moz-extension://__MSG_@@extension_id__/images/tab_thumbnail_dark.png"); border-color: #444; } @@ -81,7 +82,8 @@ .tabsAside[darkmode] .pane .collectionSet > .set > div > div > div { - background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_icon_dark.png"); + background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_icon_dark.png"), + url("moz-extension://__MSG_@@extension_id__/images/tab_icon_dark.png"); } /* Context menu style */ diff --git a/css/style.generic.css b/css/style.generic.css index 1e5b2d4..2aab2e8 100644 --- a/css/style.generic.css +++ b/css/style.generic.css @@ -27,7 +27,7 @@ { color: #0078d7; } - .tabsAside a:hover + .tabsAside a:hover { text-decoration: underline; cursor: pointer; @@ -81,8 +81,8 @@ background-color: lightgray; } - .tabsAside nav button - { + .tabsAside nav button + { text-align: start; padding: 0px 10px; @@ -98,7 +98,7 @@ } .tabsAside button + nav:active, - .tabsAside button:focus + nav + .tabsAside button:focus + nav { visibility: visible; } @@ -113,12 +113,14 @@ .btn.more { - background-image: url("chrome-extension://__MSG_@@extension_id__/icons/more.svg"); + background-image: url("chrome-extension://__MSG_@@extension_id__/icons/more.svg"), + url("moz-extension://__MSG_@@extension_id__/icons/more.svg"); } .btn.remove { - background-image: url("chrome-extension://__MSG_@@extension_id__/icons/cancel.svg"); + background-image: url("chrome-extension://__MSG_@@extension_id__/icons/cancel.svg"), + url("moz-extension://__MSG_@@extension_id__/icons/cancel.svg"); } @font-face @@ -127,5 +129,9 @@ src: local("Segoe UI"), url("chrome-extension://__MSG_@@extension_id__/fonts/WeblySleekUI/weblysleekuisemilight.ttf") format("truetype"), url("chrome-extension://__MSG_@@extension_id__/fonts/WeblySleekUI/weblysleekuisemilight.woff") format("woff"), - url("chrome-extension://__MSG_@@extension_id__/fonts/WeblySleekUI/weblysleekuisemilight.woff2") format("woff2"); + url("chrome-extension://__MSG_@@extension_id__/fonts/WeblySleekUI/weblysleekuisemilight.woff2") format("woff2"), + + url("moz-extension://__MSG_@@extension_id__/fonts/WeblySleekUI/weblysleekuisemilight.ttf") format("truetype"), + url("moz-extension://__MSG_@@extension_id__/fonts/WeblySleekUI/weblysleekuisemilight.woff") format("woff"), + url("moz-extension://__MSG_@@extension_id__/fonts/WeblySleekUI/weblysleekuisemilight.woff2") format("woff2"); } \ No newline at end of file diff --git a/js/aside-script.js b/js/aside-script.js index 2f74be6..7f4fdc8 100644 --- a/js/aside-script.js +++ b/js/aside-script.js @@ -1,4 +1,4 @@ -if (window.location === window.parent.location && window.location.protocol != "chrome-extension:") // For open/close call +if (window.location === window.parent.location && !window.location.protocol.includes("-extension:")) // For open/close call { var iframe = document.querySelector("iframe.tabsAsideIframe"); if (!iframe) @@ -52,14 +52,14 @@ function Initialize() if (window.location !== window.parent.location) { pane.setAttribute("embedded", ""); - window.addEventListener('message', event => + window.addEventListener('message', event => { if (event.data.target == "TabsAside") { pane.parentElement.style.opacity = 0; pane.removeAttribute("opened"); } - }); + }); } UpdateLocale(); @@ -80,8 +80,8 @@ function Initialize() // Tabs dismiss option var loadOnRestoreCheckbox = document.querySelector("#loadOnRestore"); chrome.storage.sync.get( - { "loadOnRestore": false }, - values => loadOnRestoreCheckbox.checked = values.loadOnRestore + { "loadOnRestore": true }, + values => loadOnRestoreCheckbox.checked = values?.loadOnRestore ?? true ); chrome.storage.onChanged.addListener((changes, namespace) => { @@ -101,7 +101,7 @@ function Initialize() var swapIconAction = document.querySelector("#swapIconAction"); chrome.storage.sync.get( { "setAsideOnClick": false }, - values => swapIconAction.checked = values.setAsideOnClick + values => swapIconAction.checked = values?.setAsideOnClick ?? false ); chrome.storage.onChanged.addListener((changes, namespace) => { @@ -137,7 +137,7 @@ function Initialize() }) ); - document.querySelectorAll(".tabsAside.pane > header nav button").forEach(i => + document.querySelectorAll(".tabsAside.pane > header nav button").forEach(i => i.onclick = () => { if (i.hasAttribute("feedback-button")) @@ -154,7 +154,7 @@ function Initialize() chrome.runtime.sendMessage({ command: "loadData" }, (collections) => { if (document.querySelector(".tabsAside.pane section div") == null) - collections.forEach(i => + collections.forEach(i => AddCollection(i)); }); @@ -165,9 +165,11 @@ function UpdateLocale() { document.querySelectorAll("*[loc]").forEach(i => i.textContent = chrome.i18n.getMessage(i.getAttribute("loc"))); document.querySelectorAll("*[loc_alt]").forEach(i => i.title = chrome.i18n.getMessage(i.getAttribute("loc_alt"))); - + var swapActionsLabel = document.querySelector("label[loc=swapIconAction]"); - chrome.commands.getAll((commands) => swapActionsLabel.textContent = swapActionsLabel.textContent.replace("%TOGGLE_SHORTCUT%", commands[2].shortcut)); + chrome.runtime.sendMessage({ command: "getShortcuts" }, (shortcuts) => + swapActionsLabel.textContent = swapActionsLabel.textContent.replace("%TOGGLE_SHORTCUT%", shortcuts.filter(i => i.name == "toggle-pane")[0].shortcut) + ); } function AddCollection(collection) @@ -207,13 +209,13 @@ function AddCollection(collection) "
" + rawTabs + "
" + ""; - + UpdateLocale(); - list.querySelectorAll(".restoreCollection").forEach(i => + list.querySelectorAll(".restoreCollection").forEach(i => i.onclick = () => RestoreTabs(i.parentElement.parentElement)); - list.querySelectorAll(".restoreCollection.noDelete").forEach(i => + list.querySelectorAll(".restoreCollection.noDelete").forEach(i => i.onclick = () => RestoreTabs(i.parentElement.parentElement.parentElement.parentElement, false)); list.querySelectorAll(".openTab").forEach(i => @@ -255,7 +257,7 @@ function RestoreTabs(collectionData, removeCollection = true) function RemoveTabs(collectionData) { - chrome.storage.sync.get({ "showDeleteDialog": true }, values => + chrome.storage.sync.get({ "showDeleteDialog": true }, values => { if (values.showDeleteDialog && !confirm(chrome.i18n.getMessage("removeCollectionConfirm"))) return; @@ -272,7 +274,7 @@ function RemoveTabs(collectionData) function RemoveOneTab(tabData) { - chrome.storage.sync.get({ "showDeleteDialog": true }, values => + chrome.storage.sync.get({ "showDeleteDialog": true }, values => { if (values.showDeleteDialog && !confirm(chrome.i18n.getMessage("removeTabConfirm"))) return; @@ -285,7 +287,7 @@ function RemoveOneTab(tabData) }, () => { - tabData.parentElement.previousElementSibling.children[0].textContent = chrome.i18n.getMessage("tabs") + ": " + (tabData.parentElement.children.length - 1); + tabData.parentElement.previousElementSibling.querySelector("small").textContent = (tabData.parentElement.children.length - 1) + " " + chrome.i18n.getMessage("tabs"); if (tabData.parentElement.children.length < 2) { RemoveElement(tabData.parentElement.parentElement); @@ -307,6 +309,6 @@ function RemoveElement(el) function RemoveCollectionElement(el) { if (el.parentElement.children.length < 3) - setTimeout(() => document.querySelector(".tabsAside.pane > section > h2").removeAttribute("hidden"), 250); + setTimeout(() => document.querySelector(".tabsAside.pane > section > h2").removeAttribute("hidden"), 250); RemoveElement(el); } \ No newline at end of file diff --git a/js/background.js b/js/background.js index 5a3ec6d..a368f71 100644 --- a/js/background.js +++ b/js/background.js @@ -2,6 +2,7 @@ function TogglePane(tab) { if (tab.url.startsWith("http") && !tab.url.includes("chrome.google.com") + && !tab.url.includes("addons.mozilla.org") && !tab.url.includes("microsoftedge.microsoft.com")) { chrome.tabs.executeScript(tab.id, @@ -21,14 +22,14 @@ function TogglePane(tab) active: true }, (activeTab) => - chrome.tabs.onActivated.addListener(function TabsAsideCloser(activeInfo) + chrome.tabs.onActivated.addListener(function TabsAsideCloser(activeInfo) { chrome.tabs.query({ url: chrome.extension.getURL("TabsAside.html") }, (result) => { if (result.length) setTimeout(() => { - result.forEach(i => + result.forEach(i => { if (activeInfo.tabId != i.id) chrome.tabs.remove(i.id); @@ -61,9 +62,9 @@ function ProcessCommand(command) chrome.browserAction.onClicked.addListener((tab) => { - chrome.storage.sync.get({ "setAsideOnClick": false }, values => + chrome.storage.sync.get({ "setAsideOnClick": false }, values => { - if (values.setAsideOnClick) + if (values?.setAsideOnClick) SaveCollection(); else TogglePane(tab); @@ -87,6 +88,8 @@ chrome.contextMenus.create( ); var collections = JSON.parse(localStorage.getItem("sets")) || []; +var shortcuts; +chrome.commands.getAll((commands) => shortcuts = commands); chrome.commands.onCommand.addListener(ProcessCommand); chrome.contextMenus.onClicked.addListener((info) => ProcessCommand(info.menuItemId)); @@ -125,12 +128,21 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => (tabs) => TogglePane(tabs[0]) ) break; + case "getShortcuts": + sendResponse(shortcuts); + break; } }); // This function updates the extension's toolbar icon function UpdateTheme() { + // Updating badge counter + chrome.browserAction.setBadgeText({ text: collections.length < 1 ? "" : collections.length.toString() }); + + if (chrome.theme) // Firefox sets theme automatically + return; + var theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; var iconStatus = collections.length ? "full" : "empty"; @@ -146,12 +158,6 @@ function UpdateTheme() "16": basePath + "16.png" } }); - - // Updating badge counter - if (collections.length < 1) - chrome.browserAction.setBadgeText({ }); - else - chrome.browserAction.setBadgeText({ text: collections.length.toString() }); } UpdateTheme(); @@ -164,7 +170,7 @@ function SaveCollection() { chrome.tabs.query({ currentWindow: true }, (rawTabs) => { - var tabs = rawTabs.filter(i => i.url != chrome.runtime.getURL("TabsAside.html") && !i.pinned && !i.url.includes("//newtab")); + var tabs = rawTabs.filter(i => i.url != chrome.runtime.getURL("TabsAside.html") && !i.pinned && !i.url.includes("//newtab") && !i.url.includes("about:blank") && !i.url.includes("about:home")); if (tabs.length < 1) { @@ -196,7 +202,7 @@ function SaveCollection() collections = JSON.parse(localStorage.getItem("sets")); var newTabId; - chrome.tabs.create({}, (tab) => + chrome.tabs.create({}, (tab) => { newTabId = tab.id; chrome.tabs.remove(rawTabs.filter(i => !i.pinned && i.id != newTabId).map(tab => tab.id)); @@ -216,7 +222,7 @@ function DeleteCollection(collectionIndex) function RestoreCollection(collectionIndex, removeCollection) { - collections[collectionIndex].links.forEach(i => + collections[collectionIndex].links.forEach(i => { chrome.tabs.create( { @@ -225,10 +231,10 @@ function RestoreCollection(collectionIndex, removeCollection) }, (createdTab) => { - chrome.storage.sync.get({ "loadOnRestore" : false }, values => + chrome.storage.sync.get({ "loadOnRestore" : true }, values => { - if (!values.loadOnRestore) - chrome.tabs.onUpdated.addListener(function DiscardTab(updatedTabId, changeInfo, updatedTab) + if (!(values?.loadOnRestore)) + chrome.tabs.onUpdated.addListener(function DiscardTab(updatedTabId, changeInfo, updatedTab) { if (updatedTabId === createdTab.id) { chrome.tabs.onUpdated.removeListener(DiscardTab); diff --git a/manifest.json b/manifest.json index 3abdee2..95c35ad 100644 --- a/manifest.json +++ b/manifest.json @@ -1,12 +1,12 @@ { "name": "__MSG_name__", - "version": "1.7", + "version": "1.7.3", "manifest_version": 2, "description": "__MSG_description__", "author": "__MSG_author__", "default_locale": "en", - "permissions": + "permissions": [ "tabs", "unlimitedStorage", @@ -14,15 +14,41 @@ "", "contextMenus" ], - - "icons": + + "icons": { "128": "icons/light/empty/128.png", "48": "icons/light/empty/48.png", "32": "icons/light/empty/32.png", "16": "icons/light/empty/16.png" }, - "browser_action": { "default_icon": "icons/light/empty/32.png" }, + "browser_action": + { + "default_icon": "icons/light/empty/32.png", + "theme_icons": + [ + { + "size": 128, + "dark": "icons/light/full/128.png", + "light": "icons/dark/full/128.png" + }, + { + "size": 48, + "dark": "icons/light/full/48.png", + "light": "icons/dark/full/48.png" + }, + { + "size": 32, + "dark": "icons/light/full/32.png", + "light": "icons/dark/full/32.png" + }, + { + "size": 16, + "dark": "icons/light/full/16.png", + "light": "icons/dark/full/16.png" + } + ] + }, "web_accessible_resources": [ "*" ], "background": @@ -51,5 +77,13 @@ "mac": "Command+Shift+P" } } + }, + "browser_specific_settings": + { + "gecko": + { + "id": "tabsaside@xfox111.net", + "strict_min_version": "58.0" + } } }