forked from Suchty112/bosernie-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersonalzuweisungsbutton.user.js
More file actions
66 lines (52 loc) · 1.96 KB
/
Personalzuweisungsbutton.user.js
File metadata and controls
66 lines (52 loc) · 1.96 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ==UserScript==
// @name * Personalzuweisungsbutton
// @namespace bos-ernie.leitstellenspiel.de
// @version 1.1.0
// @license BSD-3-Clause
// @author BOS-Ernie
// @description Fügt einen Button zur Personalzuweisung auf der Gebäudeseite und auf der Seite eines neuen Fahrzeuges hinzu
// @match https://www.leitstellenspiel.de/buildings/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=leitstellenspiel.de
// @run-at document-idle
// @grant none
// ==/UserScript==
(function () {
"use strict";
function addButtonToNewVehiclesAlert() {
const buttonGroup = document.querySelector(
"div.alert.fade.in.alert-success > div.btn-group"
);
if (buttonGroup === null) {
return;
}
const vehicleUrl = buttonGroup.children[0].href;
const userIconSpan = document.createElement("span");
userIconSpan.className = "glyphicon glyphicon-user";
const button = document.createElement("a");
button.className = "btn btn-default";
button.href = vehicleUrl + "/zuweisung";
button.appendChild(userIconSpan);
buttonGroup.appendChild(button);
}
function addButtonToVehiclesOnBuildingPage() {
const vehicleEditButtons = document.querySelectorAll(
"a.btn.btn-default.btn-xs[href^='/vehicles/'][href$='/edit']"
);
vehicleEditButtons.forEach((vehicleEditButton) => {
const vehicleUrl = vehicleEditButton.href;
const vehicleId = vehicleUrl.split("/")[4];
const userIconSpan = document.createElement("span");
userIconSpan.className = "glyphicon glyphicon-user";
const button = document.createElement("a");
button.className = "btn btn-default btn-xs";
button.href = `/vehicles/${vehicleId}/zuweisung`;
button.appendChild(userIconSpan);
vehicleEditButton.parentElement.appendChild(button);
});
}
function main() {
addButtonToNewVehiclesAlert();
addButtonToVehiclesOnBuildingPage();
}
main();
})();