0

New to chrome extensions and have the following issue:

I am trying to display recaptcha in my content script. As you know, it needs to include this <script src="https://www.google.com/recaptcha/api.js" async defer></script> tag, and since content scripts run in an isolated environment, I cannot just add it via

   const script = document.createElement('script');
   script.src = 'https://...';
   // ...and so on

This accepted answer, however, illustrates a great way of script injection into a content script, but only for local files. So is there any way to include a script from a CDN?

Oscar
  • 805
  • 2
  • 10
  • 24

1 Answers1

0

Try doing it this way:

var apiScript = document.createElement('script');  
apiScript.setAttribute('src','insert source here');
document.head.appendChild(apiScript);
Bret Hawker
  • 99
  • 1
  • 11