solobat / Steward

A command launcher for Chrome
https://oksteward.com/
669 stars 39 forks source link

detach/attach tabs #47

Closed wmertens closed 6 years ago

wmertens commented 6 years ago

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)
                )
              })
            )
          )
        )
solobat commented 6 years ago

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.

solobat commented 6 years ago

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.