nvermei1 / Timesheet brolapp

// ==UserScript==
// @name         Timesheet brolapp
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @license MIT
// @author       You
// @match        https://prjerp.prd.connect.telenet.be/projectsFinancials/faces/XxhcmMyTimeWorkarea?fnd=%3B%3B%3B%3Bfalse%3B256%3B%3B%3B&webApp=HomePage&fndHomePageViewId=%2FAtkHomePageWelcome&_adf.ctrl-state=r4k1ory0m_1&_afrLoop=1923328769337252
// @grant        none
// @require http://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==

( () => {


    $(document).keydown(function(e){
        if( e.which === 89 && e.ctrlKey ){
            // You can set an overruling default value if you want
            let vHrs, vMin, vPrj, vTsk, vRef, vCmt;
            // e.g. vCmt = 'This is the crappiest timesheeting tool I have ever witnessed.';

            // Go over each row
            document.querySelectorAll( '.xdw' ).forEach( row => {
                // but ignore the weekend
                if( !row.querySelector( '.xdx:first-child span' ).textContent.match( /^\d{2}\s(Sat|Sun)$/ ) ) {
                    // then get the input fields
                    const iHrs = row.querySelector( '.xdx:nth-child(2) input' );
                    const iMin = row.querySelector( '.xdx:nth-child(4) input' );
                    const iPrj = row.querySelector( '.xdx:nth-child(5) input' );
                    const iTsk = row.querySelector( '.xdx:nth-child(6) input' );
                    const iRef = row.querySelector( '.xdx:nth-child(7) input' );
                    const iCmt = row.querySelector( '.xdx:nth-child(8) input' );
                    // and if they have a value, save that value if there's no default, otherwise try to set the value.
                    iHrs.value && iHrs.value !== '0' ? ( vHrs = vHrs ? vHrs : iHrs.value ) : ( iHrs.value = vHrs ? vHrs : '0' );
                    iMin.value && iMin.value !== '0' ? ( vMin = vMin ? vMin : iMin.value ) : ( iMin.value = vMin ? vMin : '0' );
                    iPrj.value ? ( vPrj = vPrj ? vPrj : iPrj.value ) : ( iPrj.value = vPrj ? vPrj : '' );
                    iTsk.value ? ( vTsk = vTsk ? vTsk : iTsk.value ) : ( iTsk.value = vTsk ? vTsk : '' );
                    iRef.value ? ( vRef = vRef ? vRef : iRef.value ) : ( iRef.value = vRef ? vRef : '' );
                    iCmt.value ? ( vCmt = vCmt ? vCmt : iCmt.value ) : ( iCmt.value = vCmt ? vCmt : '' );
                }
            } );
        }
    });


} )();