简体   繁体   English

如何获取仅已创建组的列表?

[英]How to get list of only already created groups?

I know how to get list of tabs consists in certain group:我知道如何获取包含在特定组中的选项卡列表:

var possible_colors = ['grey', 'blue', 'red', 'yellow', 'green', 'pink', 'purple', 'cyan', 'orange']

chrome.tabGroups.query({ color: possible_colors[1] }, function (group) {
    chrome.tabs.query({ groupId: group[0].id }, function (tabs) {
        console.log(tabs)
    })
})

But I want to get list of only created/exists groups in current chrome window. Maybe it's somehow possible by Chrome Extensions API and without loop through all possible_colors to check like this:但我想获得当前 chrome window 中仅创建/存在的组的列表。也许 Chrome 扩展 API 在某种程度上是可能的,并且无需循环遍历所有possible_colors来检查这样的:

for (var color of possible_colors) {
    chrome.tabGroups.query({ color: color }, function (group) {
        if (!group.length) return

        chrome.tabs.query({ groupId: group[0].id }, function (tabs) {
            console.log(tabs)
        })
    })
}

Yet, found how do get all existing groups for current Chrome window:然而,发现如何获取当前 Chrome window 的所有现有组:

chrome.windows.getCurrent(function (win) {
    chrome.tabGroups.query({ windowId: win.id }, function (groups) {
         console.log(groups) // output is array of all groups
    })
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM