How would I iterate through all tabs a user has open and then check if they have a particular HTML item with id = 'item'
?
Advertisement
Answer
You can make it like this :
JavaScript
x
6
1
chrome.tabs.getAllInWindow(null, function(tabs){
2
for (var i = 0; i < tabs.length; i++) {
3
chrome.tabs.sendRequest(tabs[i].id, { action: "xxx" });
4
}
5
});
6
After that to look after your item, if you can make it like this :
JavaScript
1
2
1
document.getElementById('item')
2
Don’t forget that you can’t manipulate the HTML by using the “background page” So the first code snip is for the background page, and the second have to be on a content script 😉