From 677bdf7cd447191fe18e82d4b68dedce3c6b15df Mon Sep 17 00:00:00 2001 From: Lorenz Hohermuth Date: Mon, 21 Oct 2024 11:16:49 +0200 Subject: [PATCH] Update stomp.js --- stomp.js | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/stomp.js b/stomp.js index 74dd3fe..3aa0cc1 100644 --- a/stomp.js +++ b/stomp.js @@ -1,8 +1,8 @@ // ==UserScript== // @name stomp -// @namespace https://github.com/dmtbz -// @source https://github.com/dmtbz/stomp -// @version 1.4 +// @namespace https://git.bsiag.com/dmi +// @source https://git.bsiag.com/dmi/stomp +// @version 1.3.1 // @description try to take over the world! // @author You // @match https://services.bsi-software.com/bsicrm/* @@ -24,71 +24,55 @@ function doc_keyUp(e) { var headers = document.getElementsByClassName("table-header-item-text"); var columnPosBuchungstext; var columnPosHours; - var columnPosActivity; - const emptyCellClassName = "table-cell white-space-nowrap halign-left table-aggregate-cell empty"; for (let i = 0; i < headers.length; i++) { if (headers[i]) { if (headers[i].textContent.match(/Buchungstext/gm)) { columnPosBuchungstext = i; } else if (headers[i].textContent.match(/Dauer \[h]/gm)) { columnPosHours = i; - } else if (headers[i].textContent.match(/Aktivität/gm)) { - columnPosActivity = i; } } } var startpos; - var nodes = document.getElementsByClassName("table-row leaf first")[0].parentNode.children; + var nodes = document.getElementsByClassName("table-row first")[0].parentNode.children; for (let i = 0; i < nodes.length; i++) { - if (nodes[i].className.match(/table-row leaf (?:selected select-single )?first/g)) { + if (nodes[i].className.match(/table-row (?:selected select-single )?first/g)) { startpos = i; break; } } // 0800-1200/1245-1700[] + var totalTimeMinutes; for (let i = startpos; i < nodes.length - 1; i++) { let node = nodes[i].childNodes[columnPosBuchungstext]; let text = node.textContent; if (text && text.match(/^[0-9]{4}-[0-9]{4}(?:\/[0-9]{4}-[0-9]{4})?(?:\[[-]?[0-9]{0,2}\])?/gm)) { let morning = getMinutes(text.substring(0, 4), text.substring(5, 9)); let afternoon = getMinutes(text.substring(10, 14), text.substring(15, 19)); - let stampMinutes = morning + afternoon + parseInt(text.match(/\[([-]?[0-9]+)\]/)[1]); + totalTimeMinutes =+ morning + afternoon + parseInt(text.match(/\[([-]?[0-9]+)\]/)[1]); let n = i; - while (nodes[n].childNodes[columnPosBuchungstext].className != emptyCellClassName) { + while (nodes[n].childNodes[columnPosBuchungstext].className != "table-cell white-space-nowrap halign-left table-aggregate-cell empty") { n--; } let sumNode = nodes[n].childNodes[columnPosHours]; let actualNode = nodes[n].childNodes[columnPosBuchungstext]; let workSum = nodes[n].childNodes[columnPosHours].getElementsByClassName("text")[0].textContent.split("."); - let actualMinutes = toMinutes(parseInt(workSum[0]), parseInt(workSum[1] / 100 * 60)); - actualMinutes -= getSchoolSum(n); - if (actualMinutes === stampMinutes) { + let workSumMinutes = toMinutes(parseInt(workSum[0]), parseInt(workSum[1] / 100 * 60)); + if (workSumMinutes === totalTimeMinutes) { node.style.background = successColor; sumNode.style.background = successColor; } else { node.style.background = errorColor; sumNode.style.background = errorColor; - actualNode.textContent = "stomp: " + toHoursAndMinutes(stampMinutes); + actualNode.textContent = "stomp: " + toHoursAndMinutes(totalTimeMinutes); actualNode.style.background = errorColor; } } } - function getSchoolSum(startpos) { - for (let i = startpos + 1; (i < nodes.length - 1) && (nodes[i].childNodes[columnPosBuchungstext].className != emptyCellClassName); i++) { - let activityNode = nodes[i].childNodes[columnPosActivity]; - let activityText = activityNode.textContent; - if (activityText && activityText.match(/Lernende: Berufsschule/gm)) { - let schoolSum = nodes[i].childNodes[columnPosHours].getElementsByClassName("text")[0].textContent.split("."); - return toMinutes(parseInt(schoolSum[0]), parseInt(schoolSum[1] / 100 * 60)); - } - } - return 0; - } - function getMinutes(first, second) { var time_start = new Date(); var time_end = new Date();