Skip to content

Instantly share code, notes, and snippets.

@badboy
Forked from tie-rack/xkcd.com.js
Created March 29, 2011 14:09
Show Gist options
  • Select an option

  • Save badboy/892420 to your computer and use it in GitHub Desktop.

Select an option

Save badboy/892420 to your computer and use it in GitHub Desktop.
dotjs for adding the title text of XKCD comics on the page [no-jquery version, far more verbose, but it works]
var comic = document.querySelector("div.s img[title]");
var titleP = document.createElement("p");
titleP.style.fontVariant = "normal";
titleP.style.border = "1px solid yellow";
titleP.style.padding = "1em";
titleP.style.backgroundColor = "#FFFFCC";
titleP.innerText = comic.title;
comic.insertAdjacentElement("afterEnd", titleP);
// ==UserScript==
// @name XKCD title-text addition
// @author Jan-Erik
// @namespace http://github.com/badboy
// @version 1.0
// @description Add the image title as a textbox underneath the XKCD comic.
// @extra No more tooltip for me.
// @include http://xkcd.com/*
// ==/UserScript==
var comic = document.querySelector("div.s img[title]");
var titleP = document.createElement("p");
titleP.style.fontVariant = "normal";
titleP.style.border = "1px solid yellow";
titleP.style.padding = "1em";
titleP.style.backgroundColor = "#FFFFCC";
titleP.innerText = comic.title;
comic.insertAdjacentElement("afterEnd", titleP);
javascript:(function(){var d=document,c=d.querySelector("div.s img[title]"),t=d.createElement("p");s=t.style;s.fontVariant="normal";s.border="1px solid yellow";s.padding="1em";s.backgroundColor="#FFFFCC";t.innerText=c.title;c.insertAdjacentElement("afterEnd",t);})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment