Greasy Fork

Greasy Fork is available in English.

Explain XKCD

Adds Explain XKCD links to each XKCD comic page

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Explain XKCD
// @namespace   Alice
// @include     http*://xkcd.com/*
// @version     1.1.1
// @require     http://code.jquery.com/jquery-2.1.4.min.js
// @grant       none
// @description Adds Explain XKCD links to each XKCD comic page
// ==/UserScript==

var explain = "http://www.explainxkcd.com/wiki/index.php/";
var curPage = document.location.toString();
var pageTitle = $('#ctitle').text();
pageTitle = pageTitle.replace(/ /, "_");

if (curPage.match(/\d+/) === null) {
  curPage = $('#middleContainer').text();
  curPage = curPage.replace(/[\u0000-\uffff\n]*(Permanent link to this comic: )(http:\/\/xkcd\.com\/\d+\/)[\u0000-\uffff\n]*/gm, "$2");
}

curPage = curPage.replace(/(https?:\/\/xkcd\.com\/)(\d+)(\/)/, "$2");
explain = explain + curPage + ":_" + pageTitle;

$('#ctitle').append("<br><a href=\""+explain+"\">Explain XKCD</a>");

var tmp = $('#comic img').attr('title');
console.log(tmp);
$('#comic img').after("<p class=\"altTitle\">" + tmp + "</p>");
var style = '<style>.altTitle {\n  text-align: center;\n  font-size: 14px;\n  font-weight: bold;\n  color: black !important;\n  max-width: 600px;\n  margin: 0 auto;\n}</style>';
$('body').prepend(style);