-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMission-Patientsummary.user.js
41 lines (36 loc) · 1.24 KB
/
Mission-Patientsummary.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// ==UserScript==
// @name LSS-Mission-Patientsummary
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @description Summarizes the current patients need.
// @author Jan (jxn_30)
// @match https://www.leitstellenspiel.de/missions/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const patientIcon = document.querySelector(
'.patientPrisonerIcon[src*="patient"]'
);
if (!patientIcon) return;
const requirements = {};
Array.from(document.querySelectorAll('.mission_patient .alert-danger'))
.flatMap(alert =>
(alert.textContent?.replace(/^[^:]*:/, '').trim() || '')
.split(',')
.map(req => req.trim())
)
.filter(pat => pat)
.forEach(req => {
if (!requirements.hasOwnProperty(req)) requirements[req] = 0;
requirements[req]++;
});
const reqStr = Object.entries(requirements)
.map(([req, amount]) => `${req}: ${amount.toLocaleString()}`)
.sort()
.join(', ');
patientIcon.insertAdjacentHTML(
'afterend',
` | ${reqStr}`
);
})();