I'm writing a Google Chrome extension which manipulates the current page (basically adds a button).
In my content script, I want to load the Facebook Graph API:
$fbDiv = $(document.createElement('div')).attr('id', 'fb-root');
$fbScript = $(document.createElement('script')).attr('src', 'https://connect.facebook.net/en_US/all.js');
$(body).append($fbDiv);
$(body).append($fbScript);
console.log("fbScript: " + typeof $fbScript.get(0));
console.log("fbScript parent: " + typeof $fbScript.parent().get(0));
console.log("find through body: " + typeof $(body).find($fbScript.get(0)).get(0));
However, the script doesn't seem to added to body
. Here's the console log:
fbScript: object
fbScript parent: undefined
find through body: undefined
Any ideas on what I'm doing wrong?