XKCD Explained

Adds a button to XKCD Explained in the navigation toolbar

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 Explained
// @namespace   http://www.explainxkcd.com/
// @description Adds a button to XKCD Explained in the navigation toolbar
// @license       GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @include     http://xkcd.com/*
// @include     https://xkcd.com/*
// @grant       none
// @version     1
// ==/UserScript==
var comicNumber = parseInt(window.location.pathname.replace(/\//g,'')),
    comicNavbar = comicNavbar = document.getElementsByClassName('comicNav')[0],
    previousComicURL, comicUrl, explainNavbar;
if(!comicNumber) {
  previousComicURL = comicNavbar.children[1].firstChild.href;
  comicNumber = parseInt(previousComicURL.match('[0-9]+')) + 1;
}
comicUrl = 'http://www.explainxkcd.com/wiki/index.php?title=' + comicNumber;
explainNavbar = document.createElement('ul');

explainNavbar.className = 'comicNav';

explainNavbar.innerHTML = '<li><a target="_blank" href="' + comicUrl + '">Explanation</a></li>';
comicNavbar.parentNode.insertBefore(explainNavbar, comicNavbar);