From 00fb51fde929738522b830a45d274c03bc510cac Mon Sep 17 00:00:00 2001 From: tqjason <37337136+tqjason@users.noreply.github.com> Date: Sun, 17 May 2026 17:00:21 +0800 Subject: [PATCH] chrome-tabs-create in tmwd_cdp_bridge (#402) --- assets/tmwd_cdp_bridge/background.js | 10 ++++++++++ assets/tmwd_cdp_bridge/content.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/assets/tmwd_cdp_bridge/background.js b/assets/tmwd_cdp_bridge/background.js index 97fa88ec..6dbd4b79 100644 --- a/assets/tmwd_cdp_bridge/background.js +++ b/assets/tmwd_cdp_bridge/background.js @@ -21,6 +21,16 @@ async function handleExtMessage(msg, sender) { if (msg.cmd === 'batch') return await handleBatch(msg, sender); if (msg.cmd === 'tabs') { try { + if (msg.method === 'create') { + const tab = await chrome.tabs.create({ + url: msg.url, + active: msg.active !== undefined ? msg.active : false, + index: msg.index, + windowId: msg.windowId, + openerTabId: msg.openerTabId + }); + return { ok: true, data: { id: tab.id, url: tab.url, title: tab.title } }; + } if (msg.method === 'switch') { const tab = await chrome.tabs.update(msg.tabId, { active: true }); await chrome.windows.update(tab.windowId, { focused: true }); diff --git a/assets/tmwd_cdp_bridge/content.js b/assets/tmwd_cdp_bridge/content.js index 79dc2868..b9c337bd 100644 --- a/assets/tmwd_cdp_bridge/content.js +++ b/assets/tmwd_cdp_bridge/content.js @@ -35,7 +35,7 @@ async function handle(el) { } else if (cmd === 'batch') { resp = await chrome.runtime.sendMessage({ cmd: 'batch', commands: req.commands, tabId: req.tabId }); } else if (cmd === 'tabs') { - resp = await chrome.runtime.sendMessage({ cmd: 'tabs', method: req.method, tabId: req.tabId }); + resp = await chrome.runtime.sendMessage({ cmd: 'tabs', method: req.method, tabId: req.tabId, url: req.url, active: req.active, index: req.index, windowId: req.windowId, openerTabId: req.openerTabId }); } else { resp = { ok: false, error: 'unknown cmd: ' + cmd }; }