Skip to content

Instantly share code, notes, and snippets.

@Sitethief
Last active Jun 25, 2022
Embed
What would you like to do?
Adds card deck link to nation urls
// ==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",
'&nbsp;<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