Skip to content

Commit

Permalink
Add reopen closed tab action. Fixes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
crittermike committed Nov 17, 2017
1 parent 3dcd913 commit 9828d64
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"ecmaVersion": 6
}
}
4 changes: 3 additions & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"browsingData",
"storage",
"bookmarks",
"sessions",
"<all_urls>"
],
"options_ui": {
Expand All @@ -39,7 +40,8 @@
"scripts/contentscript.js"
],
"run_at": "document_end",
"all_frames": false
"all_frames": false,
"match_about_blank": true
}
]
}
6 changes: 6 additions & 0 deletions app/scripts.babel/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
else if (action === 'newtab') {
chrome.tabs.create({});
}
else if (action === 'reopentab') {
chrome.sessions.getRecentlyClosed({maxResults: 1}, function(sessions) {
let closedTab = sessions[0];
chrome.sessions.restore(closedTab.sessionsId);
});
}
else if (action === 'closetab') {
chrome.tabs.query({currentWindow: true, active: true}, (tab) => {
chrome.tabs.remove(tab[0].id);
Expand Down
1 change: 1 addition & 0 deletions app/scripts.babel/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ app.controller('ShortkeysOptionsCtrl', ['$scope', function($scope) {
{value:'closetab', label: 'Close tab', group: 'Tabs'},
{value:'onlytab', label: 'Close other tabs', group: 'Tabs'},
{value:'clonetab', label: 'Duplicate tab', group: 'Tabs'},
{value:'reopentab', label: 'Reopen last closed tab', group: 'Tabs'},
{value:'nexttab', label: 'Next tab', group: 'Tabs'},
{value:'prevtab', label: 'Previous tab', group: 'Tabs'},
{value:'firsttab', label: 'First tab', group: 'Tabs'},
Expand Down

0 comments on commit 9828d64

Please sign in to comment.