Azubiheft.de - Warn on to many lines

Wanrns if there are to many lines to send the report

  1. // ==UserScript==
  2. // @name Azubiheft.de - Warn on to many lines
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Wanrns if there are to many lines to send the report
  6. // @author Tim Gromeyer <tim.gromeyer@gmail.com>
  7. // @match https://www.azubiheft.de/Azubi/Wochenansicht.aspx?*
  8. // @match https://www.azubiheft.de/Azubi/Tagesbericht.aspx?*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=azubiheft.de
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. var entries = [];
  15.  
  16. if (window.location.pathname === "/Azubi/Wochenansicht.aspx") {
  17. entries = document.getElementsByClassName("d50");
  18. } else {
  19. entries = document.getElementsByClassName("row7 d5");
  20. }
  21. var entriesLength = entries.length;
  22.  
  23. var linesCount = 0;
  24.  
  25. for (var i = 0; i < entriesLength; i++) {
  26. linesCount += entries[i].childElementCount;
  27. }
  28. linesCount += entries.length;
  29.  
  30. if (linesCount > 30) {
  31. var warning = document.createElement("div");
  32. warning.className = "warning";
  33. warning.textContent = "To many lines. Reduce the number of lines to 30 or less. Current number of lines: " + linesCount;
  34.  
  35. warning.style.backgroundColor = "orange";
  36. warning.style.color = "white";
  37. warning.style.padding = "10px";
  38. warning.style.textAlign = "center";
  39. warning.style.fontWeight = "bold";
  40. warning.position = "fixed";
  41. warning.top = 0;
  42. warning.left = 0;
  43. warning.with = "100%";
  44.  
  45. document.body.insertBefore(warning, document.body.firstChild);
  46. }