Reputation: 157
Being relatively new to Chrome extensions, I have what I hope is a rather straightforward method of causing it to produce the change.
chrome.tabs.getAllInWindow(null, function(tabs) {
for(var i = 0; i < tabs.length; i++) {
chrome.tabs.update(tabs[i].id, {url: tabs[i].url});
}
});
The code above, once opened within an extension, refreshes all the tabs of the current window. Is there a similar method which will allow me to reload all the tabs in all windows, instead of just the tabs in the current window?
Upvotes: 1
Views: 3744
Reputation: 33306
Your question is not quite clear, so I may not have correctly interpreted it. I understand it to mean that you want to apply the "refresh" to every existing tab in all windows.
To do so, you can just use chrome.tabs.query()
to get all the existing tabs without limiting it to any specific window. I've made the assumption that you only want to "refresh" those tabs that are in normal windows. This will result in not "refreshing" panels which other extensions have opened, etc. If you want to do everything, then just remove `windowType:'normal'
chrome.tabs.query({windowType:'normal'}, function(tabs) {
for(var i = 0; i < tabs.length; i++) {
chrome.tabs.update(tabs[i].id, {url: tabs[i].url});
}
});
If, for some reason, you want to do it window by window instead of all in one query, you can get a list of windows from chrome.windows.getAll()
Upvotes: 5