Adds card deck link to nation urls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name NSLinkCardDeck | |
// @namespace sitethiefs-ns-scripts | |
// @version 0.3.2.beta | |
// @description Adds card deck link to nation urls | |
// @author Sitehief of Vylixan | |
// @copyright GPLv3 https://www.gnu.org/licenses/gpl-3.0.html | |
// @match *www.nationstates.net/* | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
const currentHref = window.location.href; | |
if (!document.querySelector('#nationcover')) { | |
document | |
.querySelectorAll('a') | |
.forEach(function (anchor) { | |
const href = anchor.href; | |
const possibleNatioName = href.replace('https://www.nationstates.net/nation=', '') | |
let nationname = false; | |
if (!possibleNatioName.includes('/')) { | |
nationname = possibleNatioName; | |
} | |
if (!anchor.classList.contains('quietlink') && !currentHref.includes('detail=') && href.includes('https://www.nationstates.net/nation=') && !href.includes('page=deck') && (nationname && href.endsWith(nationname))) { | |
anchor.insertAdjacentHTML( | |
"afterend", | |
' <a target="_blank" style="font-size:8px;" href="' + href + '/page=deck"><span><i class=\"icon-cards\"></i></span></a>' | |
); | |
} | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment