Hi,
I try to send a message from to global page to my injected.js on the moment that a setting changes:
global.html
function settingChanged(event) {
if(event.key == 'open') {
safari.self.tab.dispatchMessage('openChanged', safari.extension.settings['open']);
}
}
safari.extension.settings.addEventListener("change", settingChanged, false);
injected.js
// Message Event Handler
function handleMessage(e) {
if(e.name == 'openChanged') {
console.log('%o', e);
oi = e.message;
resetNSL();
}
}
// Message Event Listener
safari.self.addEventListener('message', handleMessage, false);
I don't receive the message in injected.js, what am I doing wrong??