Skip to content

Commit

Permalink
S4 support for Junk Confirmation Changer
Browse files Browse the repository at this point in the history
Co-authored-by:  aristophana <155190776+aristophana@users.noreply.github.com>
  • Loading branch information
dithpri and aristophana committed Jan 26, 2025
1 parent 4af4194 commit d792877
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions userscripts/miscellaneous/Junk Confirmation Changer.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Junk Confirmation Changer
// @namespace dithpri.RCES
// @version 0.4
// @version 0.5
// @description Change conditions for the junk confirmation alert
// @author dithpri
// @match https://www.nationstates.net/*page=deck*
Expand Down Expand Up @@ -81,6 +81,10 @@ const shouldConfirm = ({rarity, season, junkValue, name, id, region, badges, mar

/********************************/

function canonicalize(name) {
return name.toLowerCase().replaceAll(" ", "_");
}

function addOpt(...args) {
return args.filter((x) => x).reduce((acc, cur) => `${acc} ${cur}`, "");
}
Expand All @@ -95,12 +99,10 @@ function addOpt(...args) {
const junkValue = Number(junkButton.dataset.junkprice);
const season = Number(junkButton.dataset.season);

const name = card
.querySelector(".deckcard-title, .deckcard-name")
.querySelector(".nnameblock .nname")
?.textContent.toLowerCase()
.replaceAll(" ", "_");
const region = card.querySelector(".deckcard-region .rlink")?.textContent.toLowerCase().replaceAll(" ", "_");
const name = canonicalize(
card.querySelector(".deckcard .nnameblock .nname, .s4-card-wrapper a.title").textContent
);
const region = canonicalize(card.querySelector(".rlink").textContent);

const badges = [...card.querySelectorAll("img.trophy")]
.map((x) => x.src.replace(/^.*\/images\/trophies\/(.*)\.png$/, "$1"))
Expand Down

0 comments on commit d792877

Please sign in to comment.