Post

Replies

Boosts

Views

Activity

Reply to Port messages ignored in content scripts in macOS Sequoia
@tuggif No need to remove the content script from the manifest. Here's an update to the snippets I posted that would fix the problem: content.js: const port = chrome.runtime.connect({ name: 'TEST' }) // SEND MESSAGE IMMEDIATELY port.postMessage({type: 'ANYTHING'}) port.onMessage.addListener((message) => { console.log('RECEIVED TEST MESSAGE', message) }) background.js: let canSendMessage = false; chrome.runtime.onConnect.addListener((port) => { if (port.name !== 'TEST') return console.log('test port connected', port) port.onMessage.addListener((message) => { // PORT RECEIVED A MESSAGE, NOW WE CAN RESPOND canSendMessage = true console.log('SENDING PORT MESSAGE') port.postMessage('HELLO') }) })
Sep ’24