Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

220
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!