domtools / pocketknife

JS API enrichment in 15448 bytes

Scripts

Live h2 above

var h2 = create("h2", {"style":"font-style: italic;"}, "Pocket knife");
var markdownBody = body.find('.markdown-body');
markdownBody.insertBefore(h2, markdownBody.get(0));

where create is

create = function(tagname, attributes, content) {
  var element = document.createElement(tagname),
	  property;
  // element attributes
  if(typeof attributes == "object") {
	for(property in attributes) {
	  if(attributes.hasOwnProperty(property)) {
		element.setAttribute(property, attributes[property]);
	  }
	}
  }
  if (typeof attributes === "string") { content = attributes; }
  if(content) { element.innerHTML = content; }
  return element;
};

Got Access-Control-Allow-Origin error: not allowed access

get('https://api.github.com/repos/petrosh/domtools/comments', function (xhr) {
	console.log(xhr.responseText);
});