add multi browser mode to arragate data from all browsers by tabs list, tabs count, group list, group count and windows list
remove (unnamed) into the group names just leave it a empty string, remove Focused on windows how should the browser know what windows are focused
This commit is contained in:
@@ -122,7 +122,7 @@ browser-cli/
|
||||
|
||||
All commands are run with `uv run browser-cli [--browser ALIAS] <command>`.
|
||||
|
||||
If exactly one browser instance is connected, commands auto-target it. Use `--browser ALIAS` when multiple browser instances are connected. You can inspect the active instances with `browser-cli clients` and assign a persistent profile alias from inside the target browser with `browser-cli rename-profile --browser <current-alias> <new-alias>`. Closed browsers are removed from the client registry automatically.
|
||||
If exactly one browser instance is connected, commands auto-target it. Use `--browser ALIAS` when multiple browser instances are connected. `tabs list`, `tabs count`, `group list`, `group count`, and `windows list` are the only commands that aggregate across all active browsers when `--browser` is omitted; in that mode they show the source browser alias or UUID. You can inspect the active instances with `browser-cli clients` and assign a persistent profile alias from inside the target browser with `browser-cli rename-profile --browser <current-alias> <new-alias>`. Closed browsers are removed from the client registry automatically.
|
||||
|
||||
Important: profile aliases are browser-instance aliases, not window aliases. Window aliases created with `windows rename` are only for targeting windows in commands like `nav open --window work`. If a browser instance has no explicit profile alias set, the native host gives it a generated UUID alias so multiple unaliased browsers stay distinct.
|
||||
|
||||
@@ -302,27 +302,28 @@ b.forward(tab_id=1234)
|
||||
b.focus_url("github")
|
||||
|
||||
# Tabs
|
||||
tabs = b.tabs_list() # list of dicts: id, windowId, title, url, active, ...
|
||||
tabs = b.tabs_list() # list[Tab]; in multi-browser mode each tab.browser is set
|
||||
b.tabs_active(1234)
|
||||
b.tabs_close(1234)
|
||||
b.tabs_close_inactive()
|
||||
b.tabs_close_duplicates()
|
||||
b.tabs_filter("youtube") # list of matching tabs
|
||||
b.tabs_query("pull request")
|
||||
b.tabs_count("github") # int
|
||||
counts = b.tabs_count("github") # int, or BrowserCounts(total=..., by_browser=...) in multi-browser mode
|
||||
html = b.tabs_html() # full HTML string of active tab
|
||||
b.tabs_sort(by="domain")
|
||||
b.tabs_merge_windows()
|
||||
b.tabs_dedupe()
|
||||
|
||||
# Tab groups
|
||||
groups = b.group_list() # list of dicts: id, title, color, collapsed, tabCount
|
||||
groups = b.group_list() # list[Group]; in multi-browser mode each group.browser is set
|
||||
b.group_open("research") # creates group, returns { id, name }
|
||||
b.group_close(42)
|
||||
b.group_tabs(42) # tabs inside a group
|
||||
b.group_count() # int, or BrowserCounts(...) in multi-browser mode
|
||||
|
||||
# Windows
|
||||
windows = b.windows_list()
|
||||
windows = b.windows_list() # in multi-browser mode each dict has a "browser" key
|
||||
b.windows_rename(1, "work")
|
||||
b.windows_open()
|
||||
b.windows_close(1)
|
||||
@@ -368,6 +369,21 @@ except RuntimeError as e:
|
||||
print(f"Browser returned an error: {e}")
|
||||
```
|
||||
|
||||
```python
|
||||
from browser_cli import BrowserCLI, BrowserCounts
|
||||
|
||||
b = BrowserCLI()
|
||||
|
||||
tabs = b.tabs_list()
|
||||
for tab in tabs:
|
||||
print(tab.browser, tab.title)
|
||||
|
||||
counts = b.tabs_count()
|
||||
if isinstance(counts, BrowserCounts):
|
||||
print(counts.total)
|
||||
print(counts.by_browser)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Example scripts
|
||||
|
||||
Reference in New Issue
Block a user