Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
Inject Script from chrome extension

I'm trying to inject a script into a site and from everything I've tried nothing works correctly.

When I try to inject a script I get this error:

Error handling response: TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
    at chrome-extension://mjpoonklfkmkfofjemeehpkgljpkejef/popup.js:11:53

Here are my files:

popup.js

function getScript(file) {
    var script = document.createElement('script');
    script.src = chrome.runtime.getURL(file);
    document.body.appendChild(script);
}

chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => {
    let url = tabs[0].url;
    if (url.includes('discord.com')) {    
        var s = getScript('inject.js');    
        (document.head || document.documentElement).appendChild(s);
    } else {
        window.close();
    }
});

inject.js

console.log('inject.js loaded')

These also don't work on my end:

(document.body || document.documentElement).appendChild(s);

chrome.tabs.executeScript({
    code: 'console.log("Injected Code!");'
});

chrome.extension.getBackgroundPage().appendChild(s);

document.getElementsByTagName('body')[0].appendChild(s);

document.body.appendClild(s)

document.head.appendChild(s);

I'm trying to inject the script to send data to the extension.

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda