(direction, { count, tab })
| 467 | // Selects a tab before or after the currently selected tab. |
| 468 | // - direction: "next", "previous", "first" or "last". |
| 469 | function selectTab(direction, { count, tab }) { |
| 470 | chrome.tabs.query(visibleTabsQueryArgs, function (tabs) { |
| 471 | if (tabs.length > 1) { |
| 472 | const toSelect = (() => { |
| 473 | switch (direction) { |
| 474 | case "next": |
| 475 | return (getTabIndex(tab, tabs) + count) % tabs.length; |
| 476 | case "previous": |
| 477 | return ((getTabIndex(tab, tabs) - count) + (count * tabs.length)) % tabs.length; |
| 478 | case "first": |
| 479 | return Math.min(tabs.length - 1, count - 1); |
| 480 | case "last": |
| 481 | return Math.max(0, tabs.length - count); |
| 482 | } |
| 483 | })(); |
| 484 | chrome.tabs.update(tabs[toSelect].id, { active: true }); |
| 485 | } |
| 486 | }); |
| 487 | } |
| 488 | |
| 489 | chrome.webNavigation.onCommitted.addListener(async ({ tabId, frameId }) => { |
| 490 | // Vimium can't run on all tabs (e.g. chrome:// URLs). insertCSS will throw an error on such tabs, |
no test coverage detected