NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name ZohoPeopleOvertimeDeviationCalc // @description This ain't Å agrantix // @author First Son of the Lab // @include http://people.zoho.eu/paytestlab/zp#attendance/entry/tabularview/* // @include https://people.zoho.eu/paytestlab/zp#attendance/entry/tabularview/* // @include http://people.zoho.eu/paytestlab/zp#attendance/entry/* // @include https://people.zoho.eu/paytestlab/zp#attendance/entry/* // @include https://people.zoho.eu/paytestlab/zp#attendance/* // @include http://people.zoho.eu/paytestlab/zp#attendance/* // @include https://people.zoho.eu/paytestlab/zp/* // @include http://people.zoho.eu/paytestlab/zp/* // @include http://people.zoho.eu/paytestlab/* // @include https://people.zoho.eu/paytestlab/* // @exclude http://people.zoho.eu/paytestlab // @exclude https://people.zoho.eu/paytestlab // @license MIT // @version 1.0.0 // ==/UserScript== var tBodyZPAtt_tabView = document.getElementById("ZPAtt_tabViewEntries"); var tblRows = tBodyZPAtt_tabView.getElementsByTagName("tr"); var tblCells = tBodyZPAtt_tabView.getElementsByTagName("td"); var overtime = 0; var overtimeSum = 0; var deviationSum = 0; var deviation = 0; var daysWorked = 0; var overtimeDeviationBalance = 0; for (var i = 0; i < tblRows.length; i++) { if (tblRows[i].querySelector("[title='Present']") || tblRows[i].querySelector("[data-original-title='Present']")) { overtime = tblRows[i].getElementsByClassName("grn")[0] ? tblRows[i].getElementsByClassName("grn")[0].innerHTML : "00:00"; overtimeSum += timeStringToFloat(overtime); deviation = tblRows[i].getElementsByClassName("red")[0] ? tblRows[i].getElementsByClassName("red")[0].innerHTML : "00:00"; deviationSum += timeStringToFloat(deviation); daysWorked++; } } function timeStringToFloat(time) { let hoursMinutes = time.split(/[.:]/); let hours = parseInt(hoursMinutes[0], 10); let minutes = hoursMinutes[1] ? parseInt(hoursMinutes[1], 10) : 0; return hours + minutes / 60; } overtimeDeviationBalance = overtimeSum - deviationSum; var parentDiv = document.getElementById("ZPAttView_Days"); var newDiv = document.createElement("div"); newDiv.className = "Dtyps onduty-border"; newDiv.innerHTML = "<span>Overtime SUM: " + overtimeSum + ", Deviation SUM: " + deviationSum + "</span><div class='Avadat' id='ZPAtt_onDutyCount'>Stanje nadur po " + daysWorked + ". delavnikih je " + overtimeDeviationBalance + "</div>"; insertAfter(parentDiv, newDiv); function insertAfter(referenceNode, newNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); }