Explain XKCD

Adds Explain XKCD links to each XKCD comic page

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

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

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        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);