Add commas to page-header currency counters to make them more readable. (9999999 => 9,999,999)
目前為
// ==UserScript==
// @name Flight Rising - Add Commas To Page-Header Currency Counters
// @namespace https://greasyfork.org/users/547396
// @version 0.2
// @description Add commas to page-header currency counters to make them more readable. (9999999 => 9,999,999)
// @author Jicky
// @match *://*.flightrising.com
// @match *://*.flightrising.com/*
// @icon https://www.google.com/s2/favicons?domain=flightrising.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
function reformatIntegerNode(node) {
if (!node) { return false; }
var str = node.textContent.trim();
if (str.includes(',')) { return false; } // skip if already done
var num = parseInt(str);
if (isNaN(num) || num<1000 ) { return false; }
node.innerHTML = Number(num).toLocaleString();
return num;
}
function reformatTreasure() {
// NOTE: Uses '#loginbar-{CURRENCY}' on most pages, but
// '#user_{CURRENCY}' when viewing other users' lairs.
var selectors = ['span#loginbar-treasure', 'span#user_treasure'];
var node = document.querySelector(selectors);
return reformatIntegerNode(node);
}
function reformatGems() {
var selectors = ['span#loginbar-gems', 'span#user_gems'];
var node = document.querySelector(selectors);
return reformatIntegerNode(node);
}
reformatTreasure();
reformatGems();
})();