Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sitethiefs Card Utility Manager Script (SCUMS)
// ==UserScript==
// @name Sitethiefs Card Utility Manager Script (SCUMS)
// @namespace sitethiefs-ns-scripts
// @version 0.2.2.beta
// @description Highlights regions, hides cards, marks card types etc
// @author Sitethief of Vylixan
// @copyright GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
// @match *www.nationstates.net/page=deck
// @match *www.nationstates.net/page=deck*
// @match *www.nationstates.net/page=deck/*
// @match *www.nationstates.net/*/page=deck
// @match *www.nationstates.net/*/page=deck/*
// @require https://craig.global.ssl.fastly.net/js/mousetrap/mousetrap.min.js?a4098
// @run-at document-idle
// @grant GM.getValue
// @grant GM.setValue
// @grant GM_notification
// @grant GM_listValues
// @grant GM_log
// @require https://openuserjs.org/src/libs/sizzle/GM_config.min.js
// ==/UserScript==
/*
This script used to be the Region Highlighter script, but that name did not really fit the added features anymore
This is a beta version of the new features, there may be errors and bugs
Usage is at your own risk!
Report bugs to Sitethief at the Cards Discord : https://discord.gg/yn5a4p9
*/
/**
WARNING!!!!!!!
A Note on processMode!
Read this before using it!!
Please first visit the value deck on a nation where you process cards and set cards for sale
Otherwise it is possible you will junk cards that ve bids/high MV or have other criteria where you don't want to junk them.
Cards that have an ask on it by your nation are not junkable even if you press the junk button on them
This feature works best in combination with a script that offers a Keyboard key that junks cards.
First set the conditions in 'processOptions' above on true if you want to hide those cards from the deck page
Hideen cards are not junkable on the deck page
Then set 'processMode' to true
Then visit the decks of nations you want to process, and junk cards AFTER YOU VISITIED THE VALUE PAGE TO CONFIRM
WARNING!!!!!!!
I am not responsible if you junk some common inflated card, or some other card! Do not complain if you set the process options wrong!
I'm also not responsible if people get angry at you if you forget to check bids, and you junk a low owner/CTE region card where they have a bid on
Do not forget to turn the processMode flags off again after you are done with processing, otherwise your deck will look really weird!
This prcess feature is only enabled on the deck page, not while opening packs or on the value page for now
If you are the smartass that hides both seasons or both flag types, I will feel free to ridicule you when you report this as bug
**/
GM_config.init({
'id': 'SCUMS',
'title': 'Sitethiefs Card Utility Manager Script (SCUMS) Config', // Panel Title
'fields': {
'processModeText': {
'section': 'Process Mode',
'type': 'checkbox',
'label': 'WARNING!!!!!!!' +
'A Note on Process Mode!<br>' +
'Read this before using it!!<br>' +
'<br>' +
'Please first visit the value deck on a nation where you process cards and set cards for sale<br>' +
'Otherwise it is possible you will junk cards that ve bids/high MV or have other criteria where you don\'t want to junk them.<br>' +
'Cards that have an ask on it by your nation are not junkable even if you press the junk button on them<br>' +
'<br>' +
'This feature works best in combination with a script that offers a Keyboard key that junks cards.<br>' +
'First set the conditions in config you want to hide those cards from the deck page<br>' +
'Hidden cards are not junkable on the deck page<br>' +
'Then click the toggle<br>' +
'Then visit the decks of nations you want to process, and junk cards AFTER YOU VISITIED THE VALUE PAGE TO CONFIRM<br>' +
'<br>' +
'WARNING!!!!!!!<br>' +
'I am not responsible if you junk some common inflated card, or some other card you wanted to keep! Do not complain if you set the process options wrong!<br>' +
'I am also not responsible if people get angry at you if you forget to check bids, and you junk a low owner/CTE region card where they have a bid on.<br>' +
'<br>' +
'Do not forget to toggle Process Mode off again after you are done with processing, otherwise your deck will look really weird!<br>' +
'This process feature is only enabled on the deck page, not while opening packs or on the value page for now<br>' +
'<br>' +
'If you are the smartass that hides both seasons or both flag types, I will feel free to ridicule you when you report this as bug<br>',
},
'processMode': {
'label': GM_config.create('Process Mode enabled'),
'type': 'checkbox',
'default': false
},
'processModeButton': {
'label': GM_config.create('Process Mode Toggle button in menu'),
'type': 'checkbox',
'default': true
},
'processModeHideCustom': {
'label': GM_config.create('Hide Custom Flags'),
'type': 'checkbox',
'default': true
},
'processModeHideDefault': {
'label': GM_config.create('Hide Default Flags'),
'type': 'checkbox',
'default': false
},
'processModeHideSeasonTwo': {
'label': GM_config.create('Hide Season Two'),
'type': 'checkbox',
'default': false
},
'processModeHideSeasonOne': {
'label': GM_config.create('Hide Season One'),
'type': 'checkbox',
'default': true
},
'processModeHideClassCard': {
'label': GM_config.create('Hide Class Cards'),
'type': 'checkbox',
'default': true
},
'processModeHideRegionMatched': {
'label': GM_config.create('Hide Region Matched'),
'type': 'checkbox',
'default': true
},
'processModeHideFlagMatched': {
'label': GM_config.create('Hide Flag Matched'),
'type': 'checkbox',
'default': true
},
},
'events': {
'close': function () {
location.reload(true);
},
}
});
(function () {
'use strict';
const options = {
// Highlights these elements
border: true, // on condition match, sets border around card
stripe: false, // on condition match, highlights the bottom of the card
highlight_color: 'red', // Color of border and highlight
junkingRemoved: false, // on condition match, removes the junking button
showFlagType: true, // Shows the Flag type next to the card rarity, (D) for default flags and (U) for uploaded flags
blockMV: false, // condition match for cards with MV label on the pack page
blockBid: true, // condition match for cards with bid label on the pack page
blockRegions: true, // condition match for cards whose region matches regionlist
blockRarities: true, // condition match for cards whose rarity matches raritylist
junkKey: 'w', // sekrit key to still be able to junk the card if the junk button is gone
// These options can now be set from the config menu:
processMode: GM_config.get('processMode'),
processOptions: {
hideCustomFlags: GM_config.get('processModeHideCustom'), // Set this to true if you want to hide Cards with custom flags
hideNSFlags: GM_config.get('processModeHideDefault'), // Set this to true if you want to hide Cards with NS flags
hideSeasonOne: GM_config.get('processModeHideSeasonOne'), // Set this to true if you want to hide S1 cards
hideSeasonTwo: GM_config.get('processModeHideSeasonTwo'), // Set this to true if you want to hide S2 cards
hideClassCard: GM_config.get('processModeHideClassCard'), // Set this to true if you want to hide class Cards
hideRegionMatched: GM_config.get('processModeHideRegionMatched'), // Set this to true if you want to hide cards where the region matches with the region list in the 'regionlist'
hideFlagMatched: GM_config.get('processModeHideFlagMatched'), // Set this to true if you want to hide cards where the flag matches with the flag list in the 'flaglist'
}
}
// This is the list with region list matches
const regionlist = [
'the_pacific', // All cards in this region have bids on by their collectors
//'lazarus', // All cards in this region have bids on by their collectors
//'the_east_pacific', // All cards in this region have bids on by their collectors
//'the_west_pacific', // All cards in this region have bids on by their collectors
//'the_north_pacific', // All cards in this region have bids on by their collectors
//'the_south_pacific', // All cards in this region have bids on by their collectors
//'the_rejected_realms', // All cards in this region have bids on by their collectors
//'balder', no collectors anymore
//'south_pacific', no collectors anymore
//'europeia',// All cards in this region have bids on by their collectors
'10000_islands',
'the_leftist_assembly',
'the_communist_bloc',
//'social_liberal_union', // All cards in this region have bids on by their collectors
'the_internationale',
//'north_korea', // All cards in this region have bids on by their collectors
//'anarchy',// All cards in this region have bids on by their collectors
//'the_red_fleet',// All cards in this region have bids on by their collectors
'wintercrest',
'atlantian_oceania',
//'the_order_of_the_grey_wardens', // All cards in this region have bids on by their collectors
];
// List of flags that are hidden by the `hideFlagMatched` option
const flagList = [
'costa_rica',
];
let onPackPage = false;
const backElements = document.getElementsByClassName("deck-loot-box");
if (backElements.length) {
onPackPage = true;
}
function noinput_mousetrap(event) {
if (event.target.classList.contains("mousetrap")) {
event.preventDefault();
event.stopPropagation();
}
}
let onValuepage = false;
if (window.location.href.includes('value_deck=')) {
onValuepage = true
}
if (window.location.href.includes('card=') || onPackPage) {
options.processMode = false;
}
var processSwitch;
var config;
let jv = {
'COMMON': 0.01,
'UNCOMMON': 0.05,
'RARE': 0.10,
'ULTRA RARE': 0.20,
'EPIC': 0.50,
'LEGENDARY': 1.00,
};
// Place SCUMS Config
if (!config) {
config = document.createElement("div");
config.setAttribute('class', "bel");
config.innerHTML = "<div class=\"belcontent\"><a href=\"#\" onClick=\"return false;\" class=\"bellink\"><i class=\"icon-cards\"></i>SCUMS</a><div class=\"notificationnumber refreshable\" style=\"background-color:red\">Config</div></div>";
config.addEventListener(
"click",
function (event) {
GM_config.open();
},
false
);
}
if (!processSwitch && GM_config.get('processModeButton')) {
processSwitch = document.createElement("div");
processSwitch.setAttribute('class', "bel");
processSwitch.innerHTML = "<div class=\"belcontent\"><a href=\"#\" onClick=\"return false;\" class=\"bellink\"><i class=\"icon-cards\"></i>SCUMS</a><div class=\"notificationnumber refreshable\" style=\"background-color:red\">Toggle</div></div>";
processSwitch.addEventListener(
"click",
function (event) {
GM_config.set('processMode', !GM_config.get('processMode'));
GM_config.save();
location.reload(true);
},
false
);
}
if (GM_config.get('processModeButton')) {
(document.getElementsByClassName("belspacer belspacermain")[0])
.before(processSwitch);
}
(document.getElementsByClassName("belspacer belspacermain")[0])
.before(config);
document
.querySelectorAll('div.deckcard-container')
.forEach(function (container) {
let processModeRemoveEl = false;
let season = 2;
if (container.getElementsByClassName("deckcard-season-1")
.length) {
season = 1;
}
let classStatus = false;
if (container.getElementsByClassName("class_status")
.length) {
classStatus = true;
}
let infoLink = container.querySelector('.deckcard-info-cardlink a');
if (!window.location.href.includes('/card=')) {
infoLink.target = "_blank";
}
if (options.showFlagType) {
let flagElement = container.querySelector('div.deckcard > figure.front > div.deckcard-flag');
let titleElement = container.querySelector('div.deckcard > figure.front > div.deckcard-category');
if (flagElement && titleElement) {
if (flagElement.style['background-image'].includes('uploads')) {
titleElement.innerHTML = titleElement.innerHTML + '<span style="color: green;font-size: 10px;background-color: black;padding: 2px;">(U)</span>';
titleElement.addEventListener("click", function () {
infoLink.click();
});
if (options.processMode && options.processOptions.hideCustomFlags) {
processModeRemoveEl = true;
}
} else if (!flagElement.style['background-image'].includes('uploads')) {
titleElement.innerHTML = titleElement.innerHTML + '<span style="color: red;font-size: 10px;background-color: black;padding: 2px;">(D)</span>';
titleElement.addEventListener("click", function () {
infoLink.click();
});
if (options.processMode && options.processOptions.hideNSFlags) {
processModeRemoveEl = true;
}
if (options.processMode && options.processOptions.hideFlagMatched) {
let flagname = flagElement.style['background-image'].toLowerCase();
flagList.forEach(function (flag) {
if (flagname.includes(flag)) {
processModeRemoveEl = true;
}
});
}
}
}
}
let mvLabel = container.querySelector('div.deckcard > figure.front > div.deckcard-flag > div.deckcard-card-mv');
let anchor = container.querySelectorAll('div.deckcard > figure.front > div.deckcard-stripe > div.deckcard-region > a');
let bidBLock = false;
let bidLabel = container.querySelector('div.deckcard > figure.front > div.deckcard-flag > div.deckcard-card-buyers');
let rarity = container.querySelector('div.deckcard > figure.front > div.deckcard-category');
let styles = window.getComputedStyle(rarity, ':before')
let rarityText = styles.content.replace('"', '')
.replace('"', '');
if (options.blockBid && bidLabel && rarityText) {
let cardJV = jv[rarityText];
let bidValue = bidLabel.textContent.replace('BID: ', '');
if (parseFloat(bidValue) >= cardJV) {
bidBLock = true;
}
}
let mvBlock = false;
if ((options.blockMV && mvLabel)) {
let mvValue = mvLabel.textContent.replace('MV: ', '');
if (parseFloat(mvValue) >= 1.00) {
mvBlock = true;
}
}
if ((options.blockRegions && anchor[0] && regionlist.includes(anchor[0].getAttribute('href')
.replace('region=', ''))) || bidBLock || mvBlock) {
// Adds a highlight class to the card url for queue
if (options.processMode && options.processOptions.hideRegionMatched) {
processModeRemoveEl = true;
}
if (!options.processMode) {
let infoLink = container.querySelectorAll('.deckcard-info-cardlink > a')
infoLink[0].classList.add('region-highlighted-card');
if (options.stripe) {
anchor[0].parentElement.parentElement.style.backgroundColor = options.highlight_color;
}
if (options.border) {
container.style.outline = '5px ' + options.highlight_color + ' solid';
}
if (onPackPage && options.autoAddOnPackpage) {
let nextButton = container.querySelector('div.deckcard > figure.front > div.deckcard-flag > div.deckcard-info > div > button.add-to-queue');
if (nextButton) {
nextButton.click();
}
}
if (options.junkingRemoved) {
let buttons = container.querySelectorAll('div.deckcard > figure.front > div.deckcard-flag > div.deckcard-info > div.deckcard-info-cardbuttons a.deckcard-junk-button');
if (buttons[0]) {
buttons[0].classList.remove('deckcard-junk-button');
buttons[0].classList.add('region-highlighter-junk-button');
buttons[0].style.visibility = 'hidden';
buttons[0].style.display = 'none';
Mousetrap.bind([options.junkKey], function (ev) {
let elem = document.querySelector('a.region-highlighter-junk-button[data-rarity="common"], a.region-highlighter-junk-button[data-rarity="uncommon"], a.region-highlighter-junk-button[data-rarity="rare"], a.region-highlighter-junk-button[data-rarity="ultra-rare"], a.region-highlighter-junk-button[data-rarity="epic"]');
if (elem) {
elem.click();
elem.classList.remove('region-highlighter-junk-button');
elem.classList.add('disabled');
}
});
}
}
}
}
if (options.processMode && options.processOptions.hideSeasonOne && season === 1) {
processModeRemoveEl = true;
}
if (options.processMode && options.processOptions.hideSeasonTwo && season === 2) {
processModeRemoveEl = true;
}
if (options.processMode && options.processOptions.hideClassCard && classStatus) {
processModeRemoveEl = true;
}
if (options.processMode && processModeRemoveEl) {
container.parentNode.removeChild(container);
}
});
let info = document.querySelectorAll('p.info');
if (info.length && info[0] && info[0].innerHTML.includes('has been lodged.')) {
let region = document.querySelectorAll('a.rlink')[0].innerHTML;
let infoLink = document.querySelectorAll('.deckcard-info-cardlink > a')
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment