Stack Exchange
Can't get document.createElement to work
I was working on a 'Twitter verified faker'.
I made this code (to paste in your url when you're on a twitter profile):
javascript:var%20VERIFIEDFAKER='2.0';var%20s%20=%20document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='http://evertdespiegeleer.eu5.org/fakeit.js';void(0);

But for some reason it fails. When I add these tags manually (like it's in http://evertdespiegeleer.eu5.org/fakeit.js) to the twitter profile it works.
What's the problem here?
This is the code on evertdespegeleer.eu5.org/fakeit.js:
var newspan = document.createElement("span");
newspan.class = "visuallyhidden";
var newspann = document.createElement("span");
newspann.class = "icon verified verified-large-border";
var newslink = document.createElement("a");
newslink.href = "/help/verified";
newslink.class = "verified-link js-tooltip";
newslink.data-placement = "right";
newslink.data-original-title = "Verified account";
newslink.appendChild(newspann);
newspann.appendChild(newspan);
document.getElementsByTagName("h1").appendChild(newslink);



to paste in your url when you're on a twitter profile — For security reasons (at least some) browsers have removed the ability to run JavaScript through the address bar. For them you will need to use the JavaScript console or a bookmarklet instead.
Class names are assigned to elements via the className property, not the class property.
Identifiers cannot include - characters. If you want to set a data-* attribute, use the setAttribute method.
getElementsByTagName returns a NodeList (which is like an Array that contains Elements). You can't call appendChild on it, you have to call appendChild on an Element.

