Nixian / Trashsim profit in points by nixian

// ==UserScript==
// @name         Trashsim profit in points by nixian
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  try to take over the world!
// @author       Nixian
// @include        *trashsim.universeview.be*
// @grant        none
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
                    let table;
    let amprofit;
    let acprofit;
    let adprofit;
    let apoints;
    let dmprofit;
    let dcprofit;
    let ddprofit;
    let dpoints;
setProfits();
  //  calculatePoints();

   let atr = document.createElement("tr");
    let atd = document.createElement("td");
    let td1 = document.createElement("td");
    let td2 = document.createElement("td");
    let td3 = document.createElement("td");
    td2.innerHTML = "Attacker total profit in deut: ";
    atd.id = "nixianattackerprofitpoints";
    atd.innerHTML = apoints;
    atr.appendChild(td1);
    atr.appendChild(td2);
    atr.appendChild(td3);
    atr.appendChild(atd);
table[0].getElementsByTagName("tfoot")[0].appendChild(atr);
       let dtr = document.createElement("tr");
    let dtd = document.createElement("td");
    let td4 = document.createElement("td");
    let td5 = document.createElement("td");
    let td6 = document.createElement("td");
    td5.innerHTML = "Defender total profit in deut: ";
    dtd.id = "nixiandefenderprofitpoints";
    dtd.innerHTML = dpoints;
    dtr.appendChild(td4);
    dtr.appendChild(td5);
    dtr.appendChild(td6);
    dtr.appendChild(dtd);
table[1].getElementsByTagName("tfoot")[0].appendChild(dtr);
 //$(document).on('change', function(){calculatePoints();});
window.setInterval(function(){
 calculatePoints();
}, 100);
    function calculatePoints(){
setProfits();
        console.log(table[0].getElementsByTagName("tbody")[0].getElementsByTagName("td")[3].innerHTML);
        console.log(table[0].getElementsByTagName("tbody")[0].getElementsByTagName("td")[3].innerHTML!= "/");
            if(table[0].getElementsByTagName("tbody")[0].getElementsByTagName("td")[3].innerHTML!= "/" || table[0].getElementsByTagName("tbody")[0].getElementsByTagName("td")[7].innerHTML!= "/" || table[0].getElementsByTagName("tbody")[0].getElementsByTagName("td")[11].innerHTML!= "/"){
   apoints = numberWithCommas(Math.floor(amprofit/3+acprofit/2+adprofit));
   }
        else{apoints = "/";}
        if(table[1].getElementsByTagName("tbody")[0].getElementsByTagName("td")[3].innerHTML!= "/" || table[1].getElementsByTagName("tbody")[0].getElementsByTagName("td")[7].innerHTML!= "/" || table[1].getElementsByTagName("tbody")[0].getElementsByTagName("td")[11].innerHTML!= "/"){
   dpoints = numberWithCommas(Math.floor(dmprofit/3+dcprofit/2+ddprofit));
   }
                else{dpoints = "/";}

        //console.log(parseInt(table[0].getElementsByTagName("tbody")[0].getElementsByTagName("td")[3].innerHTML.replace(/(\d+).(?=\d{3}(\D|$))/g, "$1")));
        console.log(apoints);
        console.log(dpoints);
document.getElementById("nixianattackerprofitpoints").innerHTML = apoints;
        document.getElementById("nixiandefenderprofitpoints").innerHTML = dpoints;

    }
    function setProfits(){
                table = document.getElementsByClassName("resource-table");
    amprofit =parseInt(table[0].getElementsByTagName("tbody")[0].getElementsByTagName("td")[3].innerHTML.replace(/(\d+).(?=\d{3}(\D|$))/g, "$1"));
    acprofit= parseInt(table[0].getElementsByTagName("tbody")[0].getElementsByTagName("td")[7].innerHTML.replace(/(\d+).(?=\d{3}(\D|$))/g, "$1"));
    adprofit= parseInt(table[0].getElementsByTagName("tbody")[0].getElementsByTagName("td")[11].innerHTML.replace(/(\d+).(?=\d{3}(\D|$))/g, "$1"));
    apoints="/";
    dmprofit= parseInt(table[1].getElementsByTagName("tbody")[0].getElementsByTagName("td")[3].innerHTML.replace(/(\d+).(?=\d{3}(\D|$))/g, "$1"));
    dcprofit= parseInt(table[1].getElementsByTagName("tbody")[0].getElementsByTagName("td")[7].innerHTML.replace(/(\d+).(?=\d{3}(\D|$))/g, "$1"));
    ddprofit= parseInt(table[1].getElementsByTagName("tbody")[0].getElementsByTagName("td")[11].innerHTML.replace(/(\d+).(?=\d{3}(\D|$))/g, "$1"));
    dpoints="/";
    }
    function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
})();