Search code examples
javascripttampermonkey

Add a $ symbol next to number


I have this script for tamper-monkey and the script is for amazon I just want to know how to put a $ symbol next to the number thing so it looks like real money is getting into my account.

    var oof = document.getElementById("gc-ui-balance-gc-balance-value");

var lastCount = localStorage.getItem("lastCount");

oof.innerHTML = lastCount || "500";

function animateValue(id) {
    var obj = document.getElementById(id);
    var current = parseInt(obj.innerHTML);

    setInterval(function () {
        var nextCount = current++;
        localStorage.setItem("lastCount", nextCount);
        obj.innerHTML = nextCount;
    }, 0.1);
}

animateValue('gc-ui-balance-gc-balance-value')
})();

Solution

  • Is this what you're looking for?

    var oof = document.getElementById("gc-ui-balance-gc-balance-value");
    
    var lastCount = localStorage.getItem("lastCount");
    
    oof.innerText = '$' + lastCount + '.00' || "$500.00";
    
    function animateValue(id) {
        var obj = document.getElementById(id);
        var current = parseInt(localStorage.getItem("lastCount")) || 500;
    
        setInterval(function () {
            var nextCount = current++;
            localStorage.setItem("lastCount", nextCount);
            obj.innerText = '$' + nextCount + '.00';
        }, 0.1);
    }
    
    animateValue('gc-ui-balance-gc-balance-value')
    })();