Answer the question
In order to leave comments, you need to log in
How to execute code in all tabs at the same time?
Colleagues who wrote or write extensions, share your opinion, is it possible to work with several tabs at the same time? Those. execute code on a website page.
I’m reading the documentation and I can’t fully understand, can I work at the moment only with the active tab or with all? Has anyone asked this question?
Answer the question
In order to leave comments, you need to log in
Pass an empty options object to the chrome.tabs.query
function and a callback function where an array of Tab objects will be passed . Next, in the same function, describe chrome.tabs.executeScript with Tab.id. The tab state and other properties will also be passed in the Tab object.
chrome.tabs.query({}, function(tabs){
for (const tab of tabs){
chrome.tabs.executeScript(tab.id, {
// указываете параметры скрипта
});
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question