Skip to content

feat: add tabs.create support in bridge extension#314

Open
wangjc683 wants to merge 1 commit into
lsdefine:mainfrom
wangjc683:feat/bridge-tabs-create
Open

feat: add tabs.create support in bridge extension#314
wangjc683 wants to merge 1 commit into
lsdefine:mainfrom
wangjc683:feat/bridge-tabs-create

Conversation

@wangjc683
Copy link
Copy Markdown
Contributor

Summary

Restore the ability to open new browser tabs, lost after f0ff7ee removed TMWebDriver.newtab() (which relied on Tampermonkey GM_openInTab).

Changes

assets/tmwd_cdp_bridge/background.js (+6 lines)

  • Add create method to the tabs command handler in handleExtMessage
  • Calls chrome.tabs.create() with url and active options
  • Returns new tab info: { id, url, title, windowId }

TMWebDriver.py (+6 lines)

  • Add newtab(url=None, active=True) method
  • Serializes {cmd:"tabs", method:"create", ...} and routes through existing execute_js() → WS → bridge path
  • Reuses any active ext_ws session WebSocket connection

Testing

All scenarios passed (8 tabs created):

  • ✅ Open tab with active=False (background)
  • ✅ Open tab with active=True (foreground)
  • ✅ Open duplicate URLs (creates separate tabs)
  • ✅ Rapid consecutive opens (no race conditions)
  • ✅ Tested: baidu, bing, github, hackernews, zhihu, douban, bilibili

- Add 'create' method handler in background.js tabs command
- Add TMWebDriver.newtab() method to open new tabs via bridge
- Uses chrome.tabs.create API, bypassing popup blocker
- Tested with active/inactive, duplicate URLs, rapid consecutive opens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant