diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/commands.js | 20 | ||||
-rw-r--r-- | src/shared/default-settings.js | 7 | ||||
-rw-r--r-- | src/shared/validators/setting.js | 2 |
3 files changed, 21 insertions, 8 deletions
diff --git a/src/shared/commands.js b/src/shared/commands.js index 8edeb5c..bcad313 100644 --- a/src/shared/commands.js +++ b/src/shared/commands.js @@ -33,8 +33,19 @@ const openCommand = (url) => { }); }; -const tabopenCommand = (url) => { - return browser.tabs.create({ url: url }); +const tabopenCommand = (url, background = false, adjacent = false) => { + if (adjacent) { + return browser.tabs.query({ + active: true, currentWindow: true + }).then((gotTabs) => { + return browser.tabs.create({ + url: url, + active: !background, + index: gotTabs[0].index + 1 + }); + }); + } + return browser.tabs.create({ url: url, active: !background }); }; const winopenCommand = (url) => { @@ -102,7 +113,8 @@ const doCommand = (line, settings) => { return openCommand(normalizeUrl(words, settings.search)); case 't': case 'tabopen': - return tabopenCommand(normalizeUrl(words, settings.search)); + return tabopenCommand( + normalizeUrl(words, settings.search), false, settings.openAdjacentTabs); case 'w': case 'winopen': return winopenCommand(normalizeUrl(words, settings.search)); @@ -166,4 +178,4 @@ const complete = (line, settings) => { return getCompletions(line, settings); }; -export { exec, complete }; +export { exec, complete, tabopenCommand }; diff --git a/src/shared/default-settings.js b/src/shared/default-settings.js index 608890b..d691859 100644 --- a/src/shared/default-settings.js +++ b/src/shared/default-settings.js @@ -37,8 +37,8 @@ export default { "zi": { "type": "zoom.in" }, "zo": { "type": "zoom.out" }, "zz": { "type": "zoom.neutral" }, - "f": { "type": "follow.start", "newTab": false }, - "F": { "type": "follow.start", "newTab": true }, + "f": { "type": "follow.start", "newTab": false, "background": false }, + "F": { "type": "follow.start", "newTab": true, "background": false }, "H": { "type": "navigate.history.prev" }, "L": { "type": "navigate.history.next" }, "[[": { "type": "navigate.link.prev" }, @@ -61,6 +61,7 @@ export default { "twitter": "https://twitter.com/search?q={}", "wikipedia": "https://en.wikipedia.org/w/index.php?search={}" } - } + }, + "openAdjacentTabs": false }` }; diff --git a/src/shared/validators/setting.js b/src/shared/validators/setting.js index 949ab29..5fe75b2 100644 --- a/src/shared/validators/setting.js +++ b/src/shared/validators/setting.js @@ -1,6 +1,6 @@ import operations from 'shared/operations'; -const VALID_TOP_KEYS = ['keymaps', 'search', 'blacklist']; +const VALID_TOP_KEYS = ['keymaps', 'search', 'blacklist', 'openAdjacentTabs']; const VALID_OPERATION_VALUES = Object.keys(operations).map((key) => { return operations[key]; }); |