-
Notifications
You must be signed in to change notification settings - Fork 7
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
Freeze multiple tabs at once via Context menu #4
Comments
Thank you for this suggestion! I suspect that freezing so many tabs might not have the desired outcome. The bulk discarding and then reloading might even have adverse facts. Especially given how Firefox already throttles background tasks in inactive tabs. Limiting a specific site makes sense to me, so I'll consider the last suggestion (all for domain/origin) first. I will also accept pull requests that implement this behavior! Reminder to self: Figure out what happens to ServiceWorker client handles and |
This sounds straightforward, but someone picking this up should consult me on an implementation plan in this issue before submitting a pull request. |
I have revisited my decision from 2017 and will no longer expect this to be implemented. I want to keep the extension simple and minimize the permissions required to use this add-on. Working for multiple tabs requires extra permissions, so I'm not going to allow it. Sorry if this is inconvenient for you. I totally understand. Please try using another "freeze tabs" add-on from addons.mozilla.org but you're also welcome to fork under a different name as long as you're in compliance with the license :) |
When selecting multiple tabs it is surprising that only one of them is discarded. Do you think this case could be supported? It requires no more UI (I don't know about more permissions). |
This was also striking me as off, but it seems the API used for this, It is however fairly simple to determine selected tabs or even all tabs in the active window using // get discardable tabs in active window
await browser.tabs.query({windowId: tab.windowId, active: false, discarded: false})
// get discardable selected tabs in active window
await browser.tabs.query({windowId: tab.windowId, active: false, discarded: false, highlighted: true}) This doesn't seem to require extra permissions either, at least when loading the unpacked extension as temporary addon. The primary downside of this is that once you have more than one menu item it will move them all into a submenu, grouped by extension. It's still possible to at least fix the case of discarding all selected tabs without introducing additional menu options: diff --git a/background.js b/background.js
index f4866fc..1aa41d8 100644
--- a/background.js
+++ b/background.js
@@ -22,7 +22,7 @@ browser.menus.create({
contexts: ["tab"]
});
-browser.menus.onClicked.addListener(async (info, tab) => {
+const discardTab = async (tab) => {
if (tab.discarded) {
return;
}
@@ -39,6 +39,18 @@ browser.menus.onClicked.addListener(async (info, tab) => {
}
}
browser.tabs.discard(tab.id);
+}
+
+browser.menus.onClicked.addListener(async (info, tab) => {
+ // A highlighted tab is a selected tab.
+ // If the tab is not highlighted, the user clicked on a tab that is neither selected nor the active tab.
+ // If the tab is highlighted it might be the active tab or one of multiple selected tabs.
+ if (tab.highlighted) {
+ const tabs = await browser.tabs.query({windowId: tab.windowId, active: false, discarded: false, highlighted: true});
+ tabs.forEach(async (it) => await discardTab(it));
+ } else {
+ discardTab(tab);
+ }
});
browser.storage.onChanged.addListener((changes) => { Created #15 for this. |
Could you consider adding to the context menu:
freeze other tabs (aka freeze all the tabs but current)
freeze tabs to the left
freeze tabs to the right
freeze tabs from this domain
The text was updated successfully, but these errors were encountered: