chrome-tabs-create in tmwd_cdp_bridge (#402)
This commit is contained in:
1 parent
fcbd8572f1
commit
00fb51fde9
2 files changed
+11
-1
No files matched your search
@@ -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 });
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user