forked from floflo3299/LSS-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerformActionOnMultipleBuildingsInSchool.js
91 lines (69 loc) · 3.06 KB
/
PerformActionOnMultipleBuildingsInSchool.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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// ==UserScript==
// @name PerformActionOnMultipleBuildingsInSchool
// @namespace http://tampermonkey.net/
// @version v0.2
// @description try to take over the world!
// @author Silberfighter
// @match https://www.leitstellenspiel.de/buildings/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=leitstellenspiel.de
// @grant none
// ==/UserScript==
(function() {
'use strict';
var forwardClick = true
var alleWachen = document.getElementsByClassName("panel-heading personal-select-heading")
//console.log(alleWachen)
for (let ele of alleWachen){
ele.addEventListener('click', function(event){
var targetElement = event.target || event.srcElement;
addListenerToDropDown(targetElement);
}, false);
}
function addListenerToDropDown(ElementClickedOn){
waitUntilLoaded(ElementClickedOn.nextElementSibling)
}
function waitUntilLoaded(elemToCheck){
if(elemToCheck.childElementCount == 1){
//console.log("relaoded")
setTimeout(function(){
waitUntilLoaded(elemToCheck);
}, 100);
}else{
//console.log("laoded")
let allDropDownElements = elemToCheck.getElementsByTagName("li")
for (let ele of allDropDownElements){
ele.addEventListener('click', function(event){
if(forwardClick){
var targetElement = event.target || event.srcElement;
listElementClicked(targetElement);
}
}, false);
}
}
}
function listElementClicked(ElementClickedOn){
forwardClick = false
//console.log(ElementClickedOn)
//console.log(ElementClickedOn.onclick.toString())
let withOutSkill = ElementClickedOn.className == "schooling_select_available_without_education"
let courseName = '"ohneAusbildung"'
if (!withOutSkill){
courseName = '"' + ElementClickedOn.onclick.toString().split('"')[1] + '"'
}
console.log(withOutSkill)
console.log(courseName)
let allLIClasses = document.getElementsByTagName("li")
for (let ele of allLIClasses){
let relevantChoild = ele.firstElementChild
if (relevantChoild != null && (!withOutSkill && relevantChoild.className == "schooling_select_available_with_education" || withOutSkill && relevantChoild.className == "schooling_select_available_without_education")){
//console.log(relevantChoild.onclick.toString().indexOf(courseName))
if(relevantChoild.parentElement.parentElement.parentElement.parentElement.className == "panel-body"){
if(!withOutSkill && relevantChoild.onclick.toString().indexOf(courseName) >= 0 || withOutSkill && relevantChoild.className == "schooling_select_available_without_education"){
relevantChoild.click()
}
}
}
}
forwardClick = true
}
})();