Answer the question
In order to leave comments, you need to log in
How to pass a variable to the active tab in google extensions?
I'm making a chrome plugin.
in background.js I take authorization cookies from my site test4.test.com
chrome.cookies.get({"url": "http://test4.test.com", "name": "site_session"}, function(cookie) {
console.log(cookie.value);
});
Answer the question
In order to leave comments, you need to log in
In the background tab do:
chrome.tabs.query({}, function(tabs) {
for (i = 0; i < tabs.length; i++) {
chrome.tabs.sendMessage(tabs[i].id, 'Привет мир!');
}
});
chrome.extension.onMessage.addListener(function(message) {
console.log('Получено сообщение: ' + message);
});
chrome.tabs.query({active: true}, function(tabs) {
for (i = 0; i < tabs.length; i++) {
chrome.tabs.sendMessage(tabs[i].id, 'Привет мир!');
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question