xkcd: Add explainxkcd.com links to comics

This script adds the relevant explainxkcd.com link to xkcd comics.

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

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

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.

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

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: Add explainxkcd.com links to comics
// @namespace   http://tampermonkey.net/
// @author      FPX
// @description This script adds the relevant explainxkcd.com link to xkcd comics.
// @include     http://xkcd.com/*
// @include     http://www.xkcd.com/*
// @include     https://xkcd.com/*
// @include     https://www.xkcd.com/*
// @version     1.0.0.1
// @grant       none
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...
    var currentURL = document.location.href;
    var explainURL = currentURL.replace("xkcd", "explainxkcd");
    var navigationBars = document.getElementsByClassName("comicNav");
    for (var i=0; i<navigationBars.length; i++) {
        var navigation = navigationBars[i];
        var nextLink = navigation.children[3];
        var explainLine = document.createElement("li");
        navigation.insertBefore(explainLine, nextLink);
        var explainLink = document.createElement("a");
        explainLink.href = explainURL;
        explainLink.innerHTML = "Explain";
        explainLine.appendChild(explainLink);
    }
    /* var comic = document.getElementById("comic").children[0];
    var altText = comic.getAttribute("title");
    var altTextSpan = document.createElement("span");
    altTextSpan.innerHTML = altText;
    var middleContainer = document.getElementById("middleContainer");
    middleContainer.insertBefore(altTextSpan, middleContainer.children[4]); */
})();