Azubiheft.de - Warn on to many lines

Wanrns if there are to many lines to send the report

当前为 2023-09-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Azubiheft.de - Warn on to many lines
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Wanrns if there are to many lines to send the report
// @author       Tim Gromeyer <[email protected]>
// @match        https://www.azubiheft.de/Azubi/Wochenansicht.aspx?*
// @match        https://www.azubiheft.de/Azubi/Tagesbericht.aspx?*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=azubiheft.de
// @grant        none
// @license      MIT
// ==/UserScript==

var entries = [];

if (window.location.pathname === "/Azubi/Wochenansicht.aspx") {
    entries = document.getElementsByClassName("d50");
} else {
    entries = document.getElementsByClassName("row7 d5");
}
var entriesLength = entries.length;

var linesCount = 0;

for (var i = 0; i < entriesLength; i++) {
    linesCount += entries[i].childElementCount;
}
linesCount += entries.length;

if (linesCount > 30) {
    var warning = document.createElement("div");
    warning.className = "warning";
    warning.textContent = "To many lines. Reduce the number of lines to 30 or less. Current number of lines: " + linesCount;

    warning.style.backgroundColor = "orange";
    warning.style.color = "white";
    warning.style.padding = "10px";
    warning.style.textAlign = "center";
    warning.style.fontWeight = "bold";
    warning.position = "fixed";
    warning.top = 0;
    warning.left = 0;
    warning.with = "100%";

    document.body.insertBefore(warning, document.body.firstChild);
}