Greasy Fork

来自缓存

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.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           XKCD What-if mouse-hover text
// @namespace      http://greasyfork.icu/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();