Reputation: 67
I added a script to the DOM using
// in the console of facebook.com
var test = document.createElement('script');
test.src = "foo";
document.head.appendChild(test);
but the script has no access to the DOM.
Does this have to do with the same origin policy?
Upvotes: 0
Views: 91
Reputation: 3440
Here is a working solution to add JQuery:
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
Upvotes: 2