PDA

View Full Version : Add Commas to Dappervolk



Flordibel
04-15-2023, 01:54 PM
Add Commas to Dappervolk




Inspired by kittyray 's Add Commas to FR Auction House script ([Only registered and activated users can see links]), I decided to jump on the bandwagon and make a script that adds commas to Dappervolk's Bank, Header, Trades, and Shops!


[Only registered and activated users can see links]


[Only registered and activated users can see links]



After

[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]











Install the Tampermonkey version:



// ==UserScript==
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

// ==/UserScript==

let updatedPotatoes = false
let updatedSingleSale = false
let updatedAuction = false
let updatedShop = false
let updatedBank = false
let updatedHeader = false


waitForKeyElements (
".lot-field"
, potatoes
);

waitForKeyElements (
".lot-info.sale"
, singleSale
);

waitForKeyElements (
".lot-info.auction"
, auction
);

waitForKeyElements (
".text-center.prize-item"
, shop
);

waitForKeyElements (
".treasury-info"
, bank
);

waitForKeyElements (
"div.header-content"
, header
);



function potatoes() {

if (!updatedPotatoes) {
$(' div[class="lot-info"] .lot-field').each(function () {

this.innerHTML = `<span class=\"lot-key\">Flat Sale Price</span> ${Number(this.childNodes[1].nodeValue).toLocaleString()} <span class=\"icon potato small\"></span>`; })
updatedPotatoes = true;
}

}



function singleSale() {

if (!updatedSingleSale) {
$(' div[class="lot-info sale"] .lot-field').each(function () {

this.innerHTML = `<span class=\"lot-key\">Price</span> ${Number(this.childNodes[1].nodeValue).toLocaleString()} <span class=\"icon potato medium\"></span>`; })
updatedSingleSale = true;
}

}



function auction() {

if (!updatedAuction) {
$(' div[class="lot-field auction-bid"] ').each(function () {
this.childNodes[2].nodeValue = Number(this.childNodes[2].nodeValue).toLocaleString(); })

$(' div[class="lot-info auction"] .lot-field').each(function () {

if ( (this.innerHTML.includes('Current Bid')) && (this.className.indexOf("lot-field auction-bid") == -1) ) {
$(this.innerHTML = `<span class=\"lot-key auction\">Current Bid</span> ${Number(this.childNodes[1].nodeValue).toLocaleString()} <span class=\"icon potato small\"></span>`); }

if (this.innerHTML.includes('Minimum Increment')) {
$(this.innerHTML = `<span class=\"lot-key\">Minimum Increment</span> ${Number(this.childNodes[1].nodeValue).toLocaleString()} <span class=\"icon potato small\"></span>`); }

if ( (this.innerHTML.includes('Autobuy')) && (this.innerHTML.indexOf("None") == -1) ) {
$(this.innerHTML = `<span class=\"lot-key\">Autobuy</span>\n ${Number(this.childNodes[1].nodeValue).toLocaleString()} \n<span class=\"icon potato small\"></span>`); }})
}
updatedAuction = true;
}



function shop() {

if (!updatedShop) {
$('.prize-item-price').each(function () {
if (this.innerHTML.indexOf("CAD") == -1) {
this.childNodes[0].nodeValue = Number(this.childNodes[0].nodeValue).toLocaleString()}; })
updatedShop = true;
}

}

function bank() {

if (!updatedBank) {
$(' b[class="text-danger"]').each(function () {
if (this.innerHTML.indexOf("%") == -1) {
this.innerHTML = Number(this.childNodes[0].nodeValue).toLocaleString(); }})
updatedBank = true;
}
}


function header () {
if (!updatedHeader) {
$(' span[id="nav-potatoes"]').each(function () {
this.innerHTML = Number(this.childNodes[0].nodeValue).toLocaleString();
})
$(' span[id="nav-turnips"]').each(function () {
this.innerHTML = Number(this.childNodes[0].nodeValue).toLocaleString();
})

updatedHeader = true;
}
}


Install the Violentmonkey version:



// ==UserScript==
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

// ==/UserScript==

var $j = jQuery.noConflict();

let updatedPotatoes = false
let updatedSingleSale = false
let updatedAuction = false
let updatedShop = false
let updatedBank = false
let updatedHeader = false


waitForKeyElements (
".lot-field"
, potatoes
);

waitForKeyElements (
".lot-info.sale"
, singleSale
);

waitForKeyElements (
".lot-info.auction"
, auction
);

waitForKeyElements (
".text-center.prize-item"
, shop
);

waitForKeyElements (
".treasury-info"
, bank
);

waitForKeyElements (
"div.header-content"
, header
);



function potatoes() {

if (!updatedPotatoes) {
$j(' div[class="lot-info"] .lot-field').each(function () {

this.innerHTML = `<span class=\"lot-key\">Flat Sale Price</span> ${Number(this.childNodes[1].nodeValue).toLocaleString()} <span class=\"icon potato small\"></span>`; })
updatedPotatoes = true;
}

}



function singleSale() {

if (!updatedSingleSale) {
$j(' div[class="lot-info sale"] .lot-field').each(function () {

this.innerHTML = `<span class=\"lot-key\">Price</span> ${Number(this.childNodes[1].nodeValue).toLocaleString()} <span class=\"icon potato medium\"></span>`; })
updatedSingleSale = true;
}

}



function auction() {

if (!updatedAuction) {
$j(' div[class="lot-field auction-bid"] ').each(function () {
if (this.innerHTML.indexOf("None") == -1) {
this.childNodes[2].nodeValue = Number(this.childNodes[2].nodeValue).toLocaleString(); }})

$j(' div[class="lot-info auction"] .lot-field').each(function () {

if ( (this.innerHTML.includes('Current Bid')) && (this.className.indexOf("lot-field auction-bid") == -1) ) {
$j(this.innerHTML = `<span class=\"lot-key auction\">Current Bid</span> ${Number(this.childNodes[1].nodeValue).toLocaleString()} <span class=\"icon potato small\"></span>`); }

if (this.innerHTML.includes('Minimum Increment')) {
$j(this.innerHTML = `<span class=\"lot-key\">Minimum Increment</span> ${Number(this.childNodes[1].nodeValue).toLocaleString()} <span class=\"icon potato small\"></span>`); }

if ( (this.innerHTML.includes('Autobuy')) && (this.innerHTML.indexOf("None") == -1) ) {
$j(this.innerHTML = `<span class=\"lot-key\">Autobuy</span>\n ${Number(this.childNodes[1].nodeValue).toLocaleString()} \n<span class=\"icon potato small\"></span>`); }})
}
updatedAuction = true;
}



function shop() {

if (!updatedShop) {
$j('.prize-item-price').each(function () {
if (this.innerHTML.indexOf("CAD") == -1) {
this.childNodes[0].nodeValue = Number(this.childNodes[0].nodeValue).toLocaleString()}; })
updatedShop = true;
}

}


function bank() {

if (!updatedBank) {
$j(' b[class="text-danger"]').each(function () {
if (this.innerHTML.indexOf("%") == -1) {
this.innerHTML = Number(this.childNodes[0].nodeValue).toLocaleString(); }})
updatedBank = true;
}
}


function header () {
if (!updatedHeader) {
$j(' span[id="nav-potatoes"]').each(function () {
this.innerHTML = Number(this.childNodes[0].nodeValue).toLocaleString();
})
$j(' span[id="nav-turnips"]').each(function () {
this.innerHTML = Number(this.childNodes[0].nodeValue).toLocaleString();
})

updatedHeader = true;
}
}













Where DOESN'T it put commas?

Great question! It doesn't add commas to an auction's bid history or placeholder bid text, as marked with stars in the images below. It also does not show commas in the pre-purchase confirmation modal from shops or the "+[x]Potatoes" addition on some Trade Lots.



[Only registered and activated users can see links]








[Only registered and activated users can see links]








[Only registered and activated users can see links]


Why doesn't it put commas there?

Because I ran out of patience



What platforms can I use it with?

The Tampermonkey version can be used with Tampermonkey on Firefox and Chromium-based browsers. The Violentmonkey version can be used with Violentmonkey or Greasemonkey on Firefox and Chromium-based browsers. I don't know why one version won't work for both ok it was hard enough learning about arrays



Will it work with [X] script?

Probably! If you run into any conflicts, please reach out ([Only registered and activated users can see links]).

Flordibel
10-21-2023, 06:50 PM
I updated this script to include commas in the Dappervolk Bank and the Dappervolk Header! Hopefully this is a nice Quality of Life improvement. Grab the updated copy above!