* Ersthelfer

Wählt das nächstliegende Ersthelferfahrzeug aus

  1. // ==UserScript==
  2. // @name * Ersthelfer
  3. // @namespace bos-ernie.leitstellenspiel.de
  4. // @version 1.1.0
  5. // @license BSD-3-Clause
  6. // @author BOS-Ernie
  7. // @description Wählt das nächstliegende Ersthelferfahrzeug aus
  8. // @match https://*.leitstellenspiel.de/missions/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=leitstellenspiel.de
  10. // @run-at document-idle
  11. // @grant none
  12. // @resource https://forum.leitstellenspiel.de/index.php?thread/25554-script-ersthelfer-by-bos-ernie/
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. /**
  17. * Liste der Fahrzeugtypen die als Ersthelfer ausgewählt werden dürfen.
  18. *
  19. * Nicht zu verwendende Fahrzeuge auskommentieren oder entfernen. Die Liste aktueller Fahrzeugtypen wird im Forum
  20. * gepflegt (siehe Link).
  21. * https://forum.leitstellenspiel.de/index.php?thread/8406-infos-f%C3%BCr-entwickler/&postID=485487#post485487
  22. *
  23. * @type {number[]}
  24. */
  25. const firstResponderVehicleTypeIds = [
  26. 0, // LF 20
  27. 1, // LF 10
  28. 2, // DLK 23
  29. 3, // ELW 1
  30. 4, // RW
  31. 5, // GW-A
  32. 6, // LF 8/6
  33. 7, // LF 20/16
  34. 8, // LF 10/6
  35. 9, // LF 16-TS
  36. 10, // GW-Öl
  37. 11, // GW-L2-Wasser
  38. 12, // GW-Messtechnik
  39. 13, // SW 1000
  40. 14, // SW 2000
  41. 15, // SW 2000-Tr
  42. 16, // SW Kats
  43. 17, // TLF 2000
  44. 18, // TLF 3000
  45. 19, // TLF 8/8
  46. 20, // TLF 8/18
  47. 21, // TLF 16/24-Tr
  48. 22, // TLF 16/25
  49. 23, // TLF 16/45
  50. 24, // TLF 20/40
  51. 25, // TLF 20/40-SL
  52. 26, // TLF 16
  53. 27, // GW-Gefahrgut
  54. 28, // RTW
  55. 29, // NEF
  56. 30, // HLF 20
  57. 31, // RTH
  58. 32, // FuStW
  59. 33, // GW-Höhenrettung
  60. 34, // ELW 2
  61. 35, // leBefKw
  62. 36, // MTW
  63. 37, // TSF-W
  64. 38, // KTW
  65. 39, // GKW
  66. 40, // MTW-TZ
  67. 41, // MzGW (FGr N)
  68. 42, // LKW K 9
  69. 43, // BRmG R
  70. 44, // Anh DLE
  71. 45, // MLW 5
  72. 46, // WLF
  73. 47, // AB-Rüst
  74. 48, // AB-Atemschutz
  75. 49, // AB-Öl
  76. 50, // GruKw
  77. 51, // FüKw
  78. 52, // GefKw
  79. 53, // Dekon-P
  80. 54, // AB-Dekon-P
  81. 55, // KdoW-LNA
  82. 56, // KdoW-OrgL
  83. 57, // FwK
  84. 58, // KTW Typ B
  85. 59, // ELW 1 (SEG)
  86. 60, // GW-San
  87. 61, // Polizeihubschrauber
  88. 62, // AB-Schlauch
  89. 63, // GW-Taucher
  90. 64, // GW-Wasserrettung
  91. 65, // LKW 7 Lkr 19 tm
  92. 66, // Anh MzB
  93. 67, // Anh SchlB
  94. 68, // Anh MzAB
  95. 69, // Tauchkraftwagen
  96. 70, // MZB
  97. 71, // AB-MZB
  98. 72, // WaWe 10
  99. 73, // GRTW
  100. 74, // NAW
  101. 75, // FLF
  102. 76, // Rettungstreppe
  103. 77, // AB-Gefahrgut
  104. 78, // AB-Einsatzleitung
  105. 79, // SEK - ZF
  106. 80, // SEK - MTF
  107. 81, // MEK - ZF
  108. 82, // MEK - MTF
  109. 83, // GW-Werkfeuerwehr
  110. 84, // ULF mit Löscharm
  111. 85, // TM 50
  112. 86, // Turbolöscher
  113. 87, // TLF 4000
  114. 88, // KLF
  115. 89, // MLF
  116. 90, // HLF 10
  117. 91, // Rettungshundefahrzeug
  118. 92, // Anh Hund
  119. 93, // MTW-O
  120. 94, // DHuFüKw
  121. 95, // Polizeimotorrad
  122. 96, // Außenlastbehälter (allgemein)
  123. 97, // ITW
  124. 98, // Zivilstreifenwagen
  125. 100, // MLW 4
  126. 101, // Anh SwPu
  127. 102, // Anh 7
  128. 103, // FuStW (DGL)
  129. 104, // GW-L1
  130. 105, // GW-L2
  131. 106, // MTF-L
  132. 107, // LF-L
  133. 108, // AB-L
  134. 109, // MzGW SB
  135. 110, // NEA50
  136. 111, // NEA50
  137. 112, // NEA200
  138. 113, // NEA200
  139. 114, // GW-Lüfter
  140. 115, // Anh Lüfter
  141. 116, // AB-Lüfter
  142. 117, // AB-Tank
  143. 118, // Kleintankwagen
  144. 119, // AB-Lösch
  145. 120, // Tankwagen
  146. 121, // GTLF
  147. 122, // LKW 7 Lbw (FGr E)
  148. 123, // LKW 7 Lbw (FGr WP)
  149. 124, // MTW-OV
  150. 125, // MTW-Tr UL
  151. 126, // MTF Drohne
  152. 127, // GW UAS
  153. 128, // ELW Drohne
  154. 129, // ELW2 Drohne
  155. 130, // GW-Bt
  156. 131, // Bt-Kombi
  157. 132, // FKH
  158. 133, // Bt LKW
  159. 134, // Pferdetransporter klein
  160. 135, // Pferdetransporter groß
  161. 136, // Anh Pferdetransport
  162. 137, // Zugfahrzeug Pferdetransport
  163. ];
  164.  
  165. function addSelectButton() {
  166. const icon = document.createElement("span");
  167. icon.classList.add("glyphicon", "glyphicon-fire");
  168.  
  169. const firstResponderButton = document.createElement("button");
  170. firstResponderButton.classList.add("btn", "btn-primary");
  171. firstResponderButton.appendChild(icon);
  172. firstResponderButton.addEventListener("click", clickEventHandler);
  173. firstResponderButton.title = "Ersthelfer auswählen (Taste: f)";
  174.  
  175. const wrapper = document.createElement("div");
  176. wrapper.classList.add("flex-row", "flex-nowrap");
  177. wrapper.appendChild(firstResponderButton);
  178.  
  179. const iframeBottomContent = document.querySelector("#iframe-bottom-content");
  180. if (iframeBottomContent === null) {
  181. return;
  182. }
  183.  
  184. let parent = iframeBottomContent.querySelector("#mission_alliance_share_btn");
  185. if (parent === null) {
  186. parent = iframeBottomContent.querySelector("#mission_next_mission_btn");
  187. }
  188.  
  189. parent.parentElement.after(wrapper);
  190. }
  191.  
  192. function clickEventHandler(event) {
  193. event.preventDefault();
  194. selectFirstResponder();
  195. }
  196.  
  197. async function selectFirstResponder() {
  198. const checkboxes = document.getElementsByClassName("vehicle_checkbox");
  199.  
  200. let firstResponderFound = false;
  201. for (let i = 0; i < checkboxes.length; i++) {
  202. const checkbox = checkboxes[i];
  203.  
  204. if (checkbox.disabled) {
  205. continue;
  206. }
  207.  
  208. if (checkbox.checked) {
  209. continue;
  210. }
  211.  
  212. const vehicleTypeId = parseInt(checkbox.getAttribute("vehicle_type_id"));
  213. if (firstResponderVehicleTypeIds.includes(vehicleTypeId)) {
  214. checkbox.click();
  215. firstResponderFound = true;
  216.  
  217. break;
  218. }
  219. }
  220.  
  221. if (!firstResponderFound) {
  222. alert(
  223. "[Ersthelfer] Kein passendes Fahrzeug gefunden. Entweder Fahrzeuge nachladen oder erlaubte Fahrzeugtypen erweitern.",
  224. );
  225. }
  226. }
  227.  
  228. function main() {
  229. addSelectButton();
  230.  
  231. document.addEventListener("keydown", function (event) {
  232. if (event.key !== "f") {
  233. return;
  234. }
  235.  
  236. const activeElement = document.activeElement;
  237. if (activeElement.tagName.toLowerCase() === "input" && activeElement.type.toLowerCase() === "text") {
  238. return;
  239. }
  240.  
  241. selectFirstResponder();
  242. });
  243. }
  244.  
  245. main();
  246. })();