Skip to content

Instantly share code, notes, and snippets.

@jessuni
Created August 24, 2020 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessuni/dda4c63fb9c8aa8ae3711ac900bbf9ff to your computer and use it in GitHub Desktop.
Save jessuni/dda4c63fb9c8aa8ae3711ac900bbf9ff to your computer and use it in GitHub Desktop.
extension-section-1-background-2
chrome.runtime.onConnect.addListener(port => {
const tabId = port && port.sender && port.sender.tab.id
if (port.name === 'hello') {
enableIcon(tabId)
}
// disable icon when connection is closed
port.onDisconnect.addListener(() => {
disableIcon(tabId)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment