serversideup/webext-bridge

How background communicates with content

Closed this issue · 1 comments

Version

6.0.1

Current Behavior

// background
chrome.action.onClicked.addListener((tab) => {
  sendMessage('openDrawer',null,'content-script')
})
// content-script
onMessage('openDrawer',()=>{
  isOpen.value = !isOpen.value
})

But, I obtain the error

Uncaught (in promise) TypeError: When sending messages from background page, use @tabId syntax to target specific tab

Expected Behavior

I want content-script to pick up the signal normally

Steps To Reproduce

// background
chrome.action.onClicked.addListener((tab) => {
  sendMessage('openDrawer',null,'content-script')
})
// content-script
onMessage('openDrawer',()=>{
  isOpen.value = !isOpen.value
})

Anything else?

No response

I want to notify content-script when I click the plug-in icon