Skip to content

Open new tabs right beside their opener (aka. parent) tab or beside the currently active tab

License

Notifications You must be signed in to change notification settings

igorlogius/open-right-beside

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open new tabs right beside their opener (aka. parent) tab or beside the currently active tab

Short Demo Video:

demo-2023-12-14_21.29.02.mp4

Inspired by "Open Tabs Next to Current" and "Always Right" which i took a look at and found them to be a little to bi/complex. Lines of JS Code comparision: "Open Tabs Next to Current" (166), "Always Right" (121) and "Open Right Beside" (27). And no that is no typo. 27 Lines of code. I's so small, i'll even post it here:

code of background.js: let prevTabId = null; let actiTabId = null;

async function onActivated(activeInfo) { prevTabId = activeInfo.previousTabId; actiTabId = activeInfo.tabId; }

async function onCreated(newTab) { let activeTab = null; if (newTab.id === actiTabId) { activeTab = await browser.tabs.get(prevTabId); } else { activeTab = await browser.tabs.get(actiTabId); } if (newTab.windowId === activeTab.windowId) { browser.tabs.move(newTab.id, { index: activeTab.index + 1 }); prevTabId = newTab.id; } }

browser.tabs.onActivated.addListener(onActivated); browser.tabs.onCreated.addListener(onCreated);

Sidenote For people who think that the about:config setting now replaces this. Let me just say, that i found this behaviour to have been inconsistent and that is why i prefer to create this solution which as of yet never let me down.

Usage:

  1. install the add-on
  2. open tabs