TMA Script

"TMA Script"

Από την 24/09/2018. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name     TMA Script
// @version  10
// @grant    GM.xmlHttpRequest
// @include https://mytma.fe.hhi.de/*
// @description "TMA Script"

// @namespace https://greasyfork.org/users/149650
// ==/UserScript==
        
           
window.setInterval(() => {
    if (document.querySelector('#logintabelle') !== null) {
        if (document.querySelector('#user').value !== '' && document.querySelector('#passWord').value !== '') {
            document.querySelector('#wahl').click();   
        }
    } else {
        let title = document.querySelector('#formularNameDiv').innerText;
        if (title.search('Startseite') > -1) {
        
        
        
                let netto;
                let brutto;
                let total;
                let next = false;
                document.querySelectorAll('#ajaxZeitstatusDiv td').forEach((td, index, all) => {
                    let match = td.innerHTML.match(/(-?\d+:\d+) Std\. \(Nettozeit ohne Pausen\)/i);
                    if (match !== null) {
                        netto = match[1];
                    }
        
                    match = td.innerHTML.match(/(-?\d+:\d+) Std\. \(Bruttozeit inkl. Pausen\)/i);
                    if (match !== null) {
                        brutto = match[1];
                    }
        
                    match = td.innerHTML.match(/heute/i);
                    if (match !== null) {
                        total = all[index + 1].innerHTML.match(/(-?\d+:\d+)/)[1];
                        console.log(td.innerHTML, all[index + 1].innerHTML);
        
                    }
        
        
                });
                GM.xmlHttpRequest({
                    method: "POST",
                    url: "http://localhost:1234/post.php",
                    data: JSON.stringify({netto, brutto, total}),
                    headers: {
                        "Content-Type": "application/x-www-form-urlencoded"
                    }
                });
            
            window.setTimeout(() => {
                let button = document.querySelector('#nANABWES');
                if (button !== null) {
                button.click();
                } else {
                     document.querySelector('#themaAUSKUNFT').click();
                     window.setTimeout(() => {
                         document.querySelector('#nANABWES').click();
                     }, 2000);
                }
        
                //window.location.reload();
            }, 10000);
        } else if (title.search('Abwesenheit') > -1 ) {
           
        
                let colleagues = [];
                let next = false;
                document.querySelectorAll('.rundrumZelleMA').forEach((td, index, all) => {
                    console.log(td);
                    let match = td.innerHTML.match(/[a-z ]+, [a-z ]+/i);
                    if (match !== null) {
                        colleagues.push({
                            name: match[0].trim(),
                            present: td.title.search('gekommen') > -1
                        });
                    }
        
        
                });
                                console.log(colleagues);
        
                GM.xmlHttpRequest({
                    method: "POST",
                    url: "http://localhost:1234/post.php",
                    data: JSON.stringify({colleagues}),
                    headers: {
                        "Content-Type": "application/x-www-form-urlencoded"
                    }
                });
        
            window.setTimeout(() => {
                document.querySelector('#nSTART').click();
                //window.location.reload();
            }, 5000);
        }
    }
},  10000);