diff options
author | Tobias Gläßer <tobimensch@users.noreply.github.com> | 2018-10-29 09:14:40 -0400 |
---|---|---|
committer | Thomas Buckley-Houston <tom@tombh.co.uk> | 2019-06-24 09:09:58 +0300 |
commit | 86acac617be451fa693f0cdfe97dbd9d015e67f2 (patch) | |
tree | bd9f2680de1ba81c1cb3b79d17813f3f56384e6e | |
parent | 631483bbd910b90aa72cc113b19fec6f1f96c338 (diff) |
Added duplicate_tab, restore_tab commands.
-rw-r--r-- | webext/src/background/tty_commands_mixin.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/webext/src/background/tty_commands_mixin.js b/webext/src/background/tty_commands_mixin.js index 92911b1..815674b 100644 --- a/webext/src/background/tty_commands_mixin.js +++ b/webext/src/background/tty_commands_mixin.js @@ -29,9 +29,15 @@ export default MixinBase => case "/switch_to_tab": this.switchToTab(parts.slice(1).join(",")); break; + case "/duplicate_tab": + this.duplicateTab(parts.slice(1).join(",")); + break; case "/remove_tab": this.removeTab(parts.slice(1).join(",")); break; + case "/restore_tab": + this.restoreTab(); + break; case "/raw_text_request": this._rawTextRequest(parts[1], parts[2], parts.slice(3).join(",")); break; @@ -175,6 +181,24 @@ export default MixinBase => this.tabs[id] = null; } + duplicateTab(id) { + browser.tabs.duplicate(parseInt(id)); + } + + restoreTab() { + var sessionsInfo = browser.sessions.getRecentlyClosed({maxResults: 1 }); + sessionsInfo.then(this._restoreTab); + } + + _restoreTab(sessionsInfo) { + var mySessionInfo = sessionsInfo[0]; + if (mySessionInfo.tab) { + browser.sessions.restore(mySessionInfo.tab.sessionId); + } else { + browser.sessions.restore(mySessionInfo.window.sessionId); + } + } + // We use the `browser` object here rather than going into the actual content script // because the content script may have crashed, even never loaded. screenshotActiveTab() { |