jquery - Using remote JavaScript in Chrome Extensions -


is there way remote js file chrome extension?

my manifest.json looks this:

{     "name": "my extension",     "version": "0.1",     "content_scripts": [     {         "matches": ["http://*/*"],         "js": ["jquery.js", "main.js"],         "run_at": "document_end",         "all_frames": true     }     ] } 

i want use 1 javascript api, limited usage on selected domain, can't insert loaded page in chrome this:

$('head').append('<script src="http://example.com/myapi.js?key=%key%"></script>'); 

because js api alerted me, i'm using on url, haven't gave them.

i want use functions remote js. api key can fortunately registered , used on localhost.

but don't have clue, how solve problem - put remote js file able use it.

i've got idea create "virtual dom", perhaps it's not solution, because js api code can't executed.

where insert code? background page??

try script :

if(window.top == window && !document.getelementbyid('molseek')) {     if (document && document.doctype && document.doctype.name && document.doctype.name.tolowercase() == 'html') {         loadtooltip();     }     // weird guest... if got head element, try validate if no doctype...     else if (document && document.getelementsbytagname('head').length) {         loadtooltip();     }     // weird guest #2... if got title element, try validate if no doctype nor head...     else if (document && document.getelementsbytagname('title').length) {         loadtooltip();     } }  function loadtooltip(){      (function(s){         if(!window.molseek){             s.src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js';             (document.getelementsbytagname("head").item(0)||document.body).appendchild(s)         }     })(document.createelement('script'));     (function(s){         if(!window.apture){             s.src='https://location';             (document.getelementsbytagname("head").item(0)||document.body).appendchild(s)         }     })(document.createelement('script'));  } 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -