Skip to content

Instantly share code, notes, and snippets.

@Sitethief
Last active June 25, 2022 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sitethief/9c35747f1d5979dfc71ddd4bbee8d744 to your computer and use it in GitHub Desktop.
Save Sitethief/9c35747f1d5979dfc71ddd4bbee8d744 to your computer and use it in GitHub Desktop.
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