Greasy Fork is available in English.

Corona-Virus-Mapping JHU CSSE 2019-nCoV

Corona-Virus-Map JHU CSSE 2019-nCoV

Version vom 01.03.2020. Aktuellste Version

// ==UserScript==
// @name         Corona-Virus-Mapping JHU CSSE 2019-nCoV
// @namespace    https://www.arcgis.com
// @version      666.6
// @description  Corona-Virus-Map JHU CSSE 2019-nCoV
// @author       Chillchef
// @match        *.arcgis.com/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';


    var err = 0;
    var space = "\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0";

    window.addEventListener('load', function()
    {
        setTimeout(function(){calc();},500);
    }, false);

    function calc()
    {
        try
        {
            if(err < 20)
            {
                   console.log(document.getElementsByClassName("responsive-text-label"));

                   var h = document.getElementsByClassName("title no-pointer-events text-ellipsis margin-right-half");

                   var i = document.getElementsByClassName("responsive-text-label")[1];
                   var d = document.getElementsByClassName("responsive-text-label")[5];
                   var r = document.getElementsByClassName("responsive-text-label")[7];

                   var infect = i.textContent.trim();
                   var dead = d.textContent.trim();
                   var recover = r.textContent.trim();

                   var deadP = ((dead * 100)/infect).toFixed(2);
                   var recP = ((recover * 100)/ infect).toFixed(2);
                   var infP = (((infect - dead - recover)*100) / infect).toFixed(2);

                   if((navigator.language || navigator.userLanguage).toUpperCase() === "DE")
                   {
                       h[0].textContent = "Tote:  " + deadP + "%" + space + "Geheilt:  " + recP + "%" + space + "Noch infiziert: " + infP + "%";
                   }
                   else
                   {
                       h[0].textContent = "Death:  " + deadP + "%" + space + "Recovered:  " + recP + "%" + space + "Still infected: " + infP + "%";
                   }
                   //i.textContent = "\n    \n      "+deadP+"\n    \n  ";
                   //window.alert(infect + "\r\n " + dead + ":  " + deadP + "\r\n" + recover + ":  " + recP);
                   document.getElementsByClassName("title no-pointer-events text-ellipsis margin-right-half")[0].classList.remove("text-ellipsis");
            }
        }
        catch(e)
        {
            err++;
            console.log("Scripterr: " + err);
            setTimeout(function(){calc();},500);
        }
    }
    
})();