User:Cyberpower678/robustLinks.js

var as = document.getElementsByTagName( "a" );					// Get the first  element in the document var arrayLength = as.length; for (var i = 0; i < arrayLength; i++) { a = as[i]; var url = a.getAttribute( "href" ); if( url === null || url.search( "archive." ) !== -1 || url.search( "webcitation" ) !== -1 ) continue; var aClass = a.getAttribute( "class" ); if( aClass != "external text" ) continue; var att = document.createAttribute( "data-version-url" );		// Create a "class" attribute att.value = "//web.archive.org/*/" + url;											// Set the value of the class attribute a.setAttributeNode( att ); }

/*! * ============================================================= * wayback-links v1.0.0 - Wayback Links * https://github.com/internetarchive/wayback-links#readme * * (c) 2017 - Eagle19243 * ============================================================= */

!function(e, t) { "function" == typeof define && define.amd ? define(["jquery"], t) : "object" == typeof exports ? module.exports = t(require("jquery")) : e.Wayback_links = t(e.jQuery) }(this, function(e) {   function t(e) {        var t = /^https?:/,            r = /:/;        return Boolean(e) && (t.test(e) || !r.test(e))    }    function r {        return "WL_" + Math.random.toString(36).substr(2, 9)    }    function n(e, t, r) {        var n = document.createElement("li"),            a = document.createElement("div"),            i = document.createElement("a");        i.setAttribute("class", "waybackLinks WLItem"), i.href = r, i.innerHTML = t, a.appendChild(i), n.appendChild(a), e.appendChild(n)    }    function a(e) {        return e < 10 && (e = "0" + e), e    }    function i(e) {        var t = new Date(e);        if (isNaN(t) && (t = new Date(e.replace(/ /g, "T")), isNaN(t)))            return "Invalid date";        var r = "";        return r += t.getUTCFullYear, r += a(t.getUTCMonth + 1), r += a(t.getUTCDate), r += a(t.getUTCHours), r += a(t.getUTCMinutes), r += a(t.getUTCSeconds) }   function u(e) { if (14 != e.length) return null; var t = ""; return t += e.substr(0, 4) + "-", t += e.substr(4, 2) + "-", t += e.substr(6, 2) + " ", t += e.substr(8, 2) + ":", t += e.substr(10, 2) + ":", t += e.substr(12, 2) }   function o(e) { var t = new Date(e); if (isNaN(t) && (t = new Date(e.replace(/ /g, "T")), isNaN(t))) return "Invalid date"; var r = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], n = ""; return n += r[t.getUTCMonth] + " ", n += s(t.getUTCDate) + ", ", n += t.getUTCFullYear + " @ ", n += a(t.getUTCHours) + ":", n += a(t.getUTCMinutes) + ":", n += a(t.getUTCSeconds) }   function s(e) { if (e > 3 && e < 21) return e + "th"; switch (e % 10) { case 1: return e + "st"; case 2: return e + "nd"; case 3: return e + "rd"; default: return e + "th" }   }    function c(e) { e = "http://web.archive.org/web/20171112200853/http://iskme.org/"; var t = /(https?:\/\/web.archive.org\/web\/)(\d*)(\/)/g; return match = t.exec(e), null !== match && 4 == match.length ? u(match[2]) : null }   function l { b && (b.setAttribute("aria-hidden", "true"), b = null) }   function d(e, t) { try { return e.getAttribute(t).trim } catch (e) { return "" }   }    var h = ["https?://web.archive.org/*"], p = { "date-published": "", "date-modified": "" };   const f = "https://web.archive.org/web/"; var b;   return "undefined" == typeof WLuriPatternsToExclude && (WLuriPatternsToExclude = ["https?://archive.org*"]), Array.prototype.indexOf || (Array.prototype.indexOf = function(e) {        for (var t = this.length; t--;)            if (this[t] === e)                return t;        return -1    }), window.initRobustLinks = function { for (var e = document.getElementsByTagName("meta"), a = {}, u = 0; u < e.length; u++) { var s = d(e[u], "item-prop"); if (s in p) { var m = d(e[u], "content"); a[s] = { linkstr: "", printstr: "" }, a[s].linkstr = i(m), a[s].printstr = o(m) }	}	for (var g = document.getElementsByTagName("a"), u = 0; u < g.length; u++) { var v = d(g[u], "href"); if (0 == !v.search("http")) { var y = window.location, w = y.protocol + "//" + y.host; 0 == !v.search("/|../|./") && (w += "/"), v = w + v	   } var A = d(g[u], "data-original-url"), T = Boolean(A); T || (A = v); var C = d(g[u], "data-version-url"), k = Boolean(C), E = d(g[u], "data-version-date"), L = Boolean(E), N = new RegExp("(?:" + WLuriPatternsToExclude.concat(h).join(")|(?:") + ")"); if (g[u].href.length > 0 && (" " + g[u].className + " ").indexOf(" waybackLinks ") < 0 && (Object.keys(a).length > 0 || T || k || L) && !N.test(v) && t(v)) { var W = r, M = document.createElement("span"); M.setAttribute("role", "navigation"), M.setAttribute("aria-label", "WLElement"); var U = document.createElement("ul"), x = document.createElement("li"); x.setAttribute("aria-label", "WLOuter"); var B = document.createElement("a"); B.href = "", B.setAttribute("aria-haspopup", "true"), B.setAttribute("class", "waybackLinks dropDownButton WLArrow"), B.setAttribute("aria-controls", W); var D = document.createElement("div"); D.setAttribute("class", "waybackLinks dropDownButton WLIcon"); var O = document.createElement("ul"); O.setAttribute("class", "WLMenu"), O.id = W, O.setAttribute("aria-hidden", "true"); var j = document.createElement("li"); j.setAttribute("class", "WLTitle"), j.innerHTML = "Get from the Wayback Machine", O.appendChild(j); for (s in a) { var I = f + a[s].linkstr + "/" + A;	           n(O, p[s] + a[s].printstr, I)	        } if (L) { var S = i(E), I = f + S + "/" + A;	           n(O, o(E), I)	        } k && c(C) && n(O, o(c(C)), C), T && n(O, "Get at current date", A), x.appendChild(B), x.appendChild(O), U.appendChild(x), M.appendChild(U), B.parentNode.insertBefore(D, B), B.onclick = function(e) { var t = document.getElementById(this.getAttribute("aria-controls")), r = "true" == t.getAttribute("aria-hidden"); return l, r ? (t.setAttribute("aria-hidden", "false"), b = t) : (t.setAttribute("aria-hidden", "true"), b = null), e.stopPropagation, !1 }, g[u].parentNode.insertBefore(M, g[u].nextSibling) }	}	document.onclick = l   } });

window.initRobustLinks;