Skip to content

Instantly share code, notes, and snippets.

@Sitethief
Last active October 4, 2022 08:13
Show Gist options
  • Save Sitethief/5ea13e37be0e3d710b74b4a27497da92 to your computer and use it in GitHub Desktop.
Save Sitethief/5ea13e37be0e3d710b74b4a27497da92 to your computer and use it in GitHub Desktop.
Tweaks for the Card Deck page
// ==UserScript==
// @name NSDeckPagetweaks
// @namespace sitethiefs-ns-scripts
// @version 0.4.1
// @description Tweaks for the Card Deck page
// @author Sitethief of Vylixan
// @copyright GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
// @match https://www.nationstates.net/page=deck
// @match https://www.nationstates.net/page=deck/*
// @match https://www.nationstates.net/*/page=deck/*
// @match https://www.nationstates.net/*/page=deck
// @match https://www.nationstates.net/*/page=deck?*
// @match https://www.nationstates.net/page=deck?*
// @icon https://www.google.com/s2/favicons?domain=nationstates.net
// @grant none
// ==/UserScript==
(function () {
'use strict';
/**
* Configuration
*/
let bothPaginate = true; // Place pagination at the both ends of the page
let cardChanges = true; // Toggles the three options below
let showCardInfo = true; // Always shows the card info
let unObscureFlag = true; // Make the flag unobscured by any elements
let clearTitle = true; // Makes the nation title not obscure the card
/**
* End of configuration
*/
let paginateEl = document.querySelector('.paginate');
let deckFilter = document.querySelector('.deckcard-filters');
if (bothPaginate && paginateEl && deckFilter) {
let copiedPaginate = paginateEl.cloneNode(true);
deckFilter.parentNode.insertBefore(copiedPaginate, deckFilter);
let pageArrow = document.querySelectorAll('a.pagpage-arrow');
if (pageArrow.length) {
document.querySelectorAll('.paginate')
.forEach(function (paginate) {
//paginateEl.style.backgroundColor = 'pink';
});
}
}
if (cardChanges) {
let slogans = document.querySelectorAll('.deckcard-slogan');
if (slogans) {
for (var i = 0; i < slogans.length; i++) {
slogans[i].style.fontSize = '14px';
}
}
if (clearTitle) {
let cardTitles = document.querySelectorAll('.deckcard-season-2 .deckcard-title');
cardTitles.forEach(function (cardTitle) {
cardTitle.style.background = 'none';
cardTitle.style.border = 'none';
cardTitle.style.top = '3%';
cardTitle.style.padding = '0';
});
let nTypes = document.querySelectorAll('.deckcard-season-2 .nnameblock .ntype');
nTypes.forEach(function (nType) {
nType.style.mixBlendMode = 'difference';
});
let nationNames = document.querySelectorAll('.deckcard-season-2 .nnameblock .nname');
nationNames.forEach(function (nationName) {
nationName.style.mixBlendMode = 'difference';
});
}
if (showCardInfo) {
let cardStripes = document.querySelectorAll('.deckcard-stripe');
if (cardStripes && cardStripes.length) {
cardStripes.forEach(function (cardStripe) {
cardStripe.style.justifyContent = 'space-between';
});
}
let card2Infos = document.querySelectorAll('.deckcard-season-2 .deckcard-info');
if (card2Infos && card2Infos.length) {
card2Infos.forEach(function (card2Info) {
card2Info.classList.add('show');
card2Info.style.background = 'none';
if (unObscureFlag) {
let cardnumber = card2Info.querySelector('.deckcard-info-cardnumber');
if (cardnumber) {
cardnumber.style.display = 'none';
}
let queueAdd = card2Info.querySelector('.add-to-queue');
if (queueAdd) {
queueAdd.style.display = 'none';
}
let infoButton = card2Info.querySelector('.deckcard-info-cardlink');
if (infoButton) {
infoButton.style.display = 'none';
}
let buttons = card2Info.querySelector('.deckcard-info-cardbuttons');
if (buttons) {
buttons.style.marginTop = '450px';
buttons.style.zIndex = '20';
}
}
});
}
if (unObscureFlag) {
let cardDescs = document.querySelectorAll('.deckcard-season-2 .deckcard-desc');
if (cardDescs && cardDescs.length) {
cardDescs.forEach(function (cardDesc) {
cardDesc.style.display = 'none';
});
}
}
let card1Infos = document.querySelectorAll('.deckcard-season-1 .deckcard-info');
if (card1Infos && card1Infos.length) {
card1Infos.forEach(function (card1Info) {
card1Info.classList.add('show');
card1Info.style.background = 'none';
if (unObscureFlag) {
let cardnumber = card1Info.querySelector('.deckcard-info-cardnumber');
if (cardnumber) {
cardnumber.style.display = 'none';
}
let queueAdd = card1Info.querySelector('.add-to-queue');
if (queueAdd) {
queueAdd.style.display = 'none';
}
let infoButton = card1Info.querySelector('.deckcard-info-cardlink');
if (infoButton) {
infoButton.style.display = 'none';
}
let buttons = card1Info.querySelector('.deckcard-info-cardbuttons');
if (buttons) {
buttons.style.marginTop = '595px';
buttons.style.zIndex = '20';
}
}
});
}
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment