Open adjacent tabs and background tabs
This commit is contained in:
parent
a50c7dd0a2
commit
177940981e
10 changed files with 38 additions and 19 deletions
|
@ -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 };
|
||||
|
|
|
@ -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
|
||||
}`
|
||||
};
|
||||
|
|
|
@ -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];
|
||||
});
|
||||
|
|
Reference in a new issue