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

223
Visualizações
Javascript Image reference error from chrome extension service worker

I'm trying to make my own chrome extension for the first time that would capture your active tab as an image and then crop it. As you can see in the code below I used the chrome.tabs.captureVisibleTab() to get the tab as an dataURL. After that I want to convert the dataURL to an Image Object, but the service worker is responding with an Reference Error: Image is not defined. I'm just confused as to why its not valid? I am using manifest V3, so the script is running as a service worker in the background.

chrome.action.onClicked.addListener(getCurrentTab);

function getCurrentTab(){
    let capture = chrome.tabs.captureVisibleTab(null, {}, function(dataUrl){
        var img=new Image();
        img.src=dataUrl;
    });
}

And my manifest.json below if you want to take a look at that

{
    "name": "Screen to Text",
    "description": "Copies text in selected area to clipboard",
    "version": "1.0",
    "manifest_version": 3,
    "action": {
        "select": {
            "default_title": "Copy to clipboard",
            "default_icon": "icons/copy.png"
        }
    },
    "permissions": ["activeTab", "scripting"],
    "background": {
        "service_worker": "background.js"
    }
 }
about 4 years ago · Santiago Trujillo
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