[Request] Add values together based on item number.
https://i.paste.pics/2e6e70a3d7bf712ca3ca02d3f67c59a6.png
// ==UserScript==
// @name Total Calculator
// @namespace TotalCalculator
// @version 0.1
// @description Show the Total Calculation Results
// @author hacker09
// @include *
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
var Dollars, Cents; //Make the variables global
var TotalDollars = 0; //Make the variable global with the value of 0
var TotalCents = 0; //Make the variable global with the value of 0
var Lines = document.querySelectorAll("span.recent-billings-amount-bold"); //Create a variable to hold the number of the total amount of elements
for (var i = Lines.length; i--;) { //Starts the for condition
var IncreasyBy; //Create a null variable
Dollars = Lines[i].innerText.split('.')[0].replace('$',''); //Add the Dollars value to the variable and remove the $ symbol
Cents = Lines[i].innerText.split('.')[1]; //Add the Cents value to the variable
TotalDollars += parseInt(Dollars); //Sum the Amount of Dollars and add the result to another variabke
TotalCents += parseInt(Cents); //Sum the Amount of Cents and add the result to another variabke
} //Finishes the for condition
console.log('The Total Amount is $'+TotalDollars+'.'+TotalCents); //Display the total result on the browser console
})();
Trying to get a script written that totals dollar values of all the items on the page based on their item number and have the total displayed under the value of every item of the same item number. Code below (there will be about 30 entries of this same code with different item numbers and dollar amount).
I'd like the out put of the values to look like this: