src/background.js
/**
 * Handle connection from browser tabs.
 */
Handle connection from browser tabs.
Handle connection from browser tabs .
function onConnected(p) {
  p.onDisconnect.addListener(() => {
    portObjs.splice(p.sender.tab.id, 1);
  });
  p.onMessage.addListener((m) => {
    if (m.action === constants.browserActions.DEACTIVATE) {
      portObjs[p.sender.tab.id].isActivated = false;
      browser.browserAction.setIcon({
        path: '../icons/dom_delete.png',
        tabId: p.sender.tab.id,
      });
    }
  });
  portObjs[p.sender.tab.id] = {
    port: p,
    isActivated: false,
  };
}
function onConnected ( p ) { p . onDisconnect . addListener ( ( ) => { portObjs . splice ( p . sender . tab . id , 1 ) ; } ) ; p . onMessage . addListener ( ( m ) => { if ( m . action === constants . browserActions . DEACTIVATE ) { portObjs [ p . sender . tab . id ] . isActivated = false ; browser . browserAction . setIcon ( { path : '../icons/dom_delete.png' , tabId : p . sender . tab . id , } ) ; } } ) ; portObjs [ p . sender . tab . id ] = { port : p , isActivated : false , } ; }
Handle connection from browser tabs.
Handle connection from browser tabs .
// Remove port from list.