1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
{ "manifest_version": 3, "name": "TabsToWindow", "version": "1.0", "background": { "service_worker": "script.js" }, "permissions": [ "tabs", "windows" ], "commands": { "cmd": { "suggested_key": { "default": "Alt+Shift+G" }, "description": "TabsToWindow" } } } |
1 2 3 4 5 6 7 8 9 10 11 12 |
chrome.commands.onCommand.addListener(function (command) { if (command === 'cmd') { chrome.tabs.query({highlighted: true, currentWindow: true}, tabs => { const tabIds = tabs.map(tab => tab.id); chrome.windows.create({tabId: tabIds[0], type: 'normal'}, newWindow => { if (tabIds.length > 1) { chrome.tabs.move(tabIds.slice(1), {windowId: newWindow.id, index: -1}); } }); }); } }); |