NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Cuneros-Transaktionsuebersicht // @version 1.0 // @description Zeigt eine Übersicht der Transaktionen an. // @author zruF // @match https://www.cuneros.de/bank/transactions/ // @grant none // @copyright 2019, Julian Ueber (www.herrueber.de) // @require http://code.jquery.com/jquery-3.3.0.min.js // @license MIT // ==/UserScript== // ==OpenUserJS== // @author zruF // @collaborator zruF // ==/OpenUserJS== (function() { var div = document.createElement('div'), header = document.createElement('div'), headerh = document.createElement('h4'), body = document.createElement('div'); $(header).addClass("card-header"); $(headerh).text("Bilanz"); $(header).append(headerh); $(body).addClass("card-body"); $(div).addClass("card"); $(div).append(header); $(div).append(body); $(div).insertBefore($(".card").last()); window.addEventListener('load', function() { updateTransactions(body); }, false); })(); function updateTransactions(body){ var func = function getTransactions(){ $(body).empty(); var positive = 0, negative = 0; $('#transaction-table tr').each(function() { var c = $(this).find("td").eq(0).find("span").html(); c = c != undefined ? +c.replace(/\./g,"") : 0; if(c != undefined && c < 0) negative += c; if(c != undefined && c > 0) positive += c; }); var color = "green"; if(positive + negative < 0) color = "red"; var bilanzen = ['Einnahmen:<span style="color:green;"><b> ' + prettify(positive) + '</b></span> Cuneros' ,'Ausgaben:<span style="color:red;"><b> ' + prettify(negative) + '</b></span> Cuneros' ,'Gesamt:<span style="color:' + color + ';"><b> ' + prettify(positive + negative) + '</b></span> Cuneros']; $(body).append("<ul><li>"+bilanzen.join`</li><li>` + "</li>"); }; $('#transaction-table').bind("DOMSubtreeModified", func); func(); } function prettify(n){ var arr = [...(""+n)]; arr.splice((""+n).length-3,0,"."); if((""+n)[0] != '-' && (""+n).length > 6 || (""+n)[0] == '-' && (""+n).length > 7) arr.splice((""+n).length-6,0,"."); return arr.join``; }