I have opened multiple browser windows in google chrome. I want to find all the tab details in the current window browser. ie., no tab details from another browser.
So in my chrome extension, I am getting all the tab details in multiple browser windows.
When I tried, I got the extension window details (ie., popup.html)
Also, I am using Window.open() for displaying my extension (popup.html). So how I can get details of all tabs in the current browser when I clicked the extension?
Can anyone help me.?
What I have tried:
To find all tab details : -
chrome.windows.getAll({ populate: true }, function (windows) {
for (var i = 0; i < windows.length; ++i) {
var w = windows[i];
for (var j = 0; j < w.tabs.length; ++j) {
var t = w.tabs[j];
if (isValidTab(t)) {
tabs.push(t);
}
}
}
sendResponse({ tabs: tabs });
});
I tried :
chrome.tabs.query({ currentWindow: true }, function (tabs) {
tabs.forEach(function (tab) {
console.log('Tab ID: ', tab.id);
});
});