solobat / Steward

A command launcher for Chrome

Home Page:https://oksteward.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

detach/attach tabs

wmertens opened this issue · comments

I don't have time right now to make a PR for the tabs plugin, but I wrote a quick extension to detach a tab and also to attach all tabs from a window.

The attaching doesn't always work but the detach seems ok.

This is the relevant code:

detach:

     chrome.tabs.getSelected(null, t => {
        if (t.id >= 0)
	        chrome.windows.create({tabId: t.id, focused: true})
      })}

attach, not so great code, with deprecated calls:

		chrome.windows.getLastFocused(null, ({id}) =>
          chrome.tabs.getAllInWindow(id, newTabs =>
			chrome.windows.getCurrent(({id:windowId}) =>
	          chrome.tabs.getAllInWindow(windowId, currentTabs => {
	            let i = currentTabs.length
    	        newTabs.forEach(({id: tabId}) =>
					chrome.tabs.move(tabId, {windowId, index: i++}, console.log)
				)
			  })
            )
          )
        )

Steward has now opened the api, and most of the plugins will be aggregated into this repo. The feature you need, I will add it into the steward-plugins repo. By then, you can install it using spm install.

The plugin has been developed and uploaded to the repository. You can install it using spm install windowtabs. The det / att commands correspond to detach and attach respectively.