From 36b33c90cbfa4935efe5af01900bddf684376ddf Mon Sep 17 00:00:00 2001 From: Tobias Laundal Date: Thu, 16 Nov 2017 20:01:21 +0100 Subject: [PATCH] Add key combination to open new tab in the same container. While waiting for Bugzilla bug Bug 1406371 this should be a nice workaround. The keys Ctrl+Y are now bound to create a new tab in the same container as the current tab. --- webextension/js/background/assignManager.js | 14 ++++++++++++++ webextension/manifest.json | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/webextension/js/background/assignManager.js b/webextension/js/background/assignManager.js index f9a647d..31a5c74 100644 --- a/webextension/js/background/assignManager.js +++ b/webextension/js/background/assignManager.js @@ -177,6 +177,20 @@ const assignManager = { browser.webRequest.onBeforeRequest.addListener((options) => { return this.onBeforeRequest(options); },{urls: [""], types: ["main_frame"]}, ["blocking"]); + + browser.commands.onCommand.addListener(command => { + return this._onCommandHandler(command); + }); + }, + + async _onCommandHandler(command) { + if (command === "new-tab-container") { + return browser.tabs.query({active: true, lastFocusedWindow: true}).then(tabs => { + return tabs[0]; + }).then(tab => { + return browser.tabs.create({cookieStoreId: tab.cookieStoreId}); + }); + } }, async _onClickedHandler(info, tab) { diff --git a/webextension/manifest.json b/webextension/manifest.json index 5346437..8634876 100644 --- a/webextension/manifest.json +++ b/webextension/manifest.json @@ -38,6 +38,12 @@ "mac": "MacCtrl+Period" }, "description": "Open containers panel" + }, + "new-tab-container": { + "suggested_key": { + "default": "Ctrl+Y" + }, + "description": "Open new tab with the same container" } },