Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var totals=["C-Bills","MC","GXP","GSP", "Day Active Premium Time"];
- var text='';
- var text_rows=[];
- function summarize(item_type, collection) {
- if (collection.length == 0)
- return '';
- collection=collection.sort();
- var summarized_text ='<br>'+(collection.length)+' '+ item_type +' items:<br>';
- new Set(collection).forEach(
- (value) => summarized_text += (
- collection.reduce(
- (running, current) => current === value ? ++running : running, 0
- ) + 'x '+value+'<br>'
- )
- );
- return summarized_text;
- }
- function collection_sum(collection) {
- return collection.reduce(
- function(running,value){
- return running += parseFloat(value.replace(',','').split(' ')[0]) <<0
- },0
- )
- }
- function indexOf_factory(needle) {
- return function(haystack) {
- return haystack.indexOf(needle)>=0;
- }
- }
- function indexOf_any(haystack, needlebook){
- for(var i=0;i<needlebook.length;i++)
- if (haystack.indexOf(needlebook[i])>=0)
- return true;
- return false;
- }
- $(".dataRow td[class^='mode_'],.dataRowBonus td[class^='bonusRow_']").map(
- function() {
- text_rows.push( $(this).text() )
- }
- );
- totals.map(
- function(category){
- text+=collection_sum(text_rows.filter(indexOf_factory(category)))+' '+category+'<br>'
- }
- );
- text+= summarize('cockpit', text_rows.filter(indexOf_factory("Cockpit")).map((element) => element.substring(8)))+
- summarize('consumable', text_rows.filter(indexOf_factory("CBill")).map((element) => element.substring(6)))+
- summarize('other', text_rows.filter((value) => !(indexOf_any(value,totals.concat(["Cockpit","CBill"])))));
- $("body").append("<div style='position: fixed;bottom: 0px;right: 0px;color: white;background-color: black;'><h4>"+text+"</h4></div>");
Advertisement
Add Comment
Please, Sign In to add comment