0

I would like to inject this particular script into the HTML of a website. I'm writing a chrome extension and I just don't know how to turn this script into javascript or injecting it and then execute it. In the end, I just want to execute this script after everything has been loaded including my other scripts for the extensions. ``

<script async defer src="https://apis.google.com/js/api.js"
  onload="this.onload=function(){};handleClientLoad()"
  onreadystatechange="if (this.readyState === 'complete') this.onload()">
</script>

``

Tienanh Nguyen
  • 211
  • 4
  • 9
  • 1
    why would you be using jQuery in a chrome extension? ... just inject the HTML into the page - with the right manifest settings, that should be super simple – Jaromanda X Mar 29 '17 at 03:54
  • I mean I know how to inject a script that is a .js file, but this script looks weird. I don't understand much of it but it is needed to access to google API so all I want to do is loaded it in. – Tienanh Nguyen Mar 29 '17 at 04:00
  • it's actually more HTML than anything – Jaromanda X Mar 29 '17 at 04:13
  • 1
    How do you want to inject it? Under what conditions do you want to inject it? Into what pages? Into the `head`? The `body`? Before anything else loads? After the DOM loads? After everything loads? When the user clicks a `browserAction` button? We need significantly more detail as to what you want if we are going to write something. – Makyen Mar 29 '17 at 04:13
  • basically the same as putting this script at the end of body. – Tienanh Nguyen Mar 29 '17 at 04:14
  • does it guarantee that the script going to be executed? – Tienanh Nguyen Mar 29 '17 at 04:19
  • No, right, my stupidity (I've even provided answer saying how to do it right; brain glitch). Give me a second and I'll point you at an appropriate answer which shows how to do that. Here: [Insert code into the page context using a content script](http://stackoverflow.com/a/9517879) Basically, you will need to programmatically build the element. – Makyen Mar 29 '17 at 04:20
  • Try adding content scripts. Read [this](https://developer.chrome.com/extensions/content_scripts) – MUT Mar 29 '17 at 07:55

0 Answers0