diff --git a/background_scripts/main.js b/background_scripts/main.js index ab8eb9e19..7d91cc16f 100644 --- a/background_scripts/main.js +++ b/background_scripts/main.js @@ -254,7 +254,16 @@ const BackgroundCommands = { // In Firefox, Ctrl-W will not close a pinned tab, but on Chrome, it will. We try to be // consistent with each browser's UX for pinned tabs. if (tab.pinned && BgUtils.isFirefox()) return; - chrome.tabs.remove(tab.id); + if(Settings.get("keepLastTabOpen")){ + chrome.tabs.query({ currentWindow: true }, function (tabs) { + if(tabs.length == 1){ + chrome.tabs.create({ url: Settings.get("newTabUrl") }); + } + chrome.tabs.remove(tab.id); + }); + } else { + chrome.tabs.remove(tab.id); + } }); }, restoreTab: mkRepeatCommand((request, callback) => diff --git a/lib/settings.js b/lib/settings.js index 3663af266..140878b2f 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -69,6 +69,7 @@ w: https://www.wikipedia.org/w/index.php?title=Special:Search&search=%s Wikipedi waitForEnterForFilteredHints: true, helpDialog_showAdvancedCommands: false, ignoreKeyboardLayout: false, + keepLastTabOpen: false, }; /* diff --git a/pages/options.html b/pages/options.html index 9562e9eb4..f68ae0d65 100644 --- a/pages/options.html +++ b/pages/options.html @@ -232,6 +232,20 @@ +