function handleMessages(event) {
  if (!isAllowed()) return;
  if (!event || event.source !== window || typeof event.data !== 'object') return;
  const message = event.data;
  if (message.source !== pageSource) return;
  if (message.type === 'DISCONNECT') {
    if (bg) {
      bg.disconnect();
      connected = false;
    }
    return;
  }

  tryCatch(send, message);
}
function handleMessages(event) {
  if (!isAllowed()) return;
  if (!event || event.source !== window || typeof event.data !== 'object') return;
  const message = event.data;
  if (message.source !== pageSource) return;
  if (message.type === 'DISCONNECT') {
    if (bg) {
      bg.disconnect();
      connected = false;
    }
    return;
  }

  tryCatch(send, message);
}
function handleMessages ( event ) { if ( ! isAllowed ( ) ) return ; if ( ! event || event . source !== window || typeof event . data !== 'object' ) return ; const message = event . data ; if ( message . source !== pageSource ) return ; if ( message . type === 'DISCONNECT' ) { if ( bg ) { bg . disconnect ( ) ; connected = false ; } return ; } tryCatch ( send , message ) ; }
Resend messages from the page to the background script
Resend messages from the page to the background script
Handle messages from the page