Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

228
Visualizações
How to connect popup script to content script on chrome internal browser pages?

I'm trying to send a message to the content script running on the page in the active tab. This works fine for any normal page. However, when I try to do this for pages starting with chrome:// in the URL I get an error:

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

This is the code I'm trying to run:

// popup.js
window.addEventListener('load', (event) => {
    // In case the next line yields chrome://new-tab-page
    // or chrome://extensions for example
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
        // Request data from app
        chrome.tabs.sendMessage(tabs[0].id, "siteData", function(response) {
            // error!
            // Log app's response
        }
    }
}

//content script (even though it doesn't reach the content script)
// Site Data request
chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        if (request === "siteData") {
            sendResponse({siteList: siteList, site: site, hostname: hostname});
        }
    }
);

Is it possible at all to establish a connection with a content script on an internal chrome page? Does the internal page even execute the content script?

Thank you

Edit: This Can you access chrome:// pages from an extension? answered my question.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda