Greasy Fork is available in English.

XKCD What-if mouse-hover text

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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

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

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

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

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.

(I already have a user style manager, let me install it!)

// ==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();