code: 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);
  }
docs: Resend messages from the page to the background script