XKCD What-if mouse-hover text

This script displays mouse-hover text of what-if images as simple image captions.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name           XKCD What-if mouse-hover text
// @namespace      https://greasyfork.org/users/98-jonnyrobbie
// @author         JonnyRobbie
// @grant		   none
// @description    This script displays mouse-hover text of what-if images as simple image captions.
// @include        /^https?:\/\/(www\.)?what-if\.xkcd\.com\/([0-9]+\/)?$/
// @run-at         document-end
// @version        1.0
// ==/UserScript==

/*
CHANGELOG:
1.0
-initial release
*/

function main() {
	var illus = document.getElementsByClassName('illustration');
	for (var i=0; i<illus.length; i++) {
		var titleText = document.createElement('div');
		titleText.innerHTML = illus[i].title;
		titleText.className = "title-text";
		titleText.style.lineHeight = "1.7em";
		titleText.style.fontFamily = "Georgia,Times,serif";
		titleText.style.fontSize = "0.8em";
		titleText.style.fontStyle = "italic";
		titleText.style.textAlign = "center";
		titleText.style.margin = "auto";
		titleText.style.width = "40%";
		illus[i].parentNode.insertBefore(titleText, illus[i].nextSibling);
	}
}

main();