vt portal

working time for vt portal

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         vt portal
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  working time for vt portal
// @author       NullPointer
// @license      MIT
// @match        https://visualtime.ibermatica.com/VTPortal/2/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ibermatica.com
// @run-at document-start
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==

(function() {
    'use strict';

    var menu = document.createElement("div");
    menu.setAttribute("id", "vtmenu");
    menu.setAttribute("style", "position: absolute; z-index: 100; top: 0px; left: 100px; display: block; padding: 11px; color: #080;");
    menu.setAttribute("align", "left");

    window.setTimeout(function() {
        document.getElementsByTagName("body")[0].appendChild(menu);
        if(window.addEventListener) {
            document.getElementsByTagName("body")[0].addEventListener('DOMSubtreeModified', _calc, false);
        } else if(window.attachEvent) {
            document.getElementsByTagName("body")[0].attachEvent('DOMSubtreeModified', _calc, false);
        }
        _calc();
    }, 5000);

    function _calc() {
        var lastCalc = GM_getValue("lastCalc", 0);
        if ((new Date().getTime()) - lastCalc > 10000) {
            window.setTimeout(function(){calc();}, 1000);
            GM_setValue("lastCalc", new Date().getTime());
        }
    }

    function calc() {
        var t = 0;
        var coll = document.getElementsByClassName("listMenuItemContent");
        for (let i = coll.length - 1; i >= 0; i--) {
            var c = coll[i].innerHTML.split('<div data-bind="text: $data.Name">')[1].split('</div>')[0];
            var hm = c.split(":");
            var d = new Date();
            d.setHours(hm[1].trim() * 1, hm[2].trim() * 1, 0);
            if (c.startsWith("Entrada")) {
                if (i == coll.length - 1) {
                    t += new Date().getTime();
                }
                t -= d.getTime();
            } else {
                t += d.getTime();
            }
        }
        var dd = new Date(t);
        var h = dd.getHours() - 1;
        var m = dd.getMinutes();
        document.getElementById("vtmenu").innerHTML = ((h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m);
    }

})();