Answer the question
In order to leave comments, you need to log in
How to pass value to chrome.alarms in Chrome extension?
How to pull chrome.alarms from script inside DOM.
wanted through the localStorage variable, but chrome api chtoli does not have access there.
The bottom line is that if there is an element A on the page,
after a while, run chrome.alarms
Answer the question
In order to leave comments, you need to log in
dimonfreeman , I see, well, you stupidly asked a question, so it looks like I gave you the wrong answer.
If you need to trigger an alert on a background page, then the algorithm changes a bit. The problem here is that only the content script (scripts.js) can send a message to the background process (background.js), so you need to use it as an intermediary.
So, for starters, in the background.js file, put a message listener like this:
chrome.extension.onMessage.addListener(function(message) {
console.log('Из контент-скрипта получено следующее сообщение: ' + message);
if (message == 'вызвать алерт') {
// Здесь впишите ваш код для вызова алерта
}
});
window.addEventListener('message', function(event) {
// Извлекаем текст сообщения:
var dom_message = event.data;
console.log('Из DOM получено сообщение: ' + dom_message);
// Пересылаем полученное сообщение
// в фоновый процесс background.js:
chrome.extension.sendMessage(event.data);
});
window.postMessage('вызвать алерт', '*');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question