forked from floflo3299/LSS-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter all missions by zip-code.user.js
72 lines (52 loc) · 2.72 KB
/
filter all missions by zip-code.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
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
// ==UserScript==
// @name filter Missions by zip code
// @namespace http://tampermonkey.net/
// @version 1
// @description filter all missions by zip-code
// @author Silberfighter
// @match https://www.leitstellenspiel.de/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=leitstellenspiel.de
// @grant none
// ==/UserScript==
(function() {
'use strict';
if(document.getElementById('btn-group-mission-select')){
var from = -1;
var to = -1;
var newWindow = document.createElement("div");
text = `bis: <input style="display:inline-block; color: #000; width:80px;" type="number" id="bisPLZ" min="1" value=""></input>`;
newWindow.innerHTML = text;
$('#btn-group-mission-select').after(newWindow);
newWindow = document.createElement("div");
text = `von: <input style="display:inline-block; color: #000; width:80px;" type="number" id="vonPLZ" min="1" value=""></input>`;
newWindow.innerHTML = text;
$('#btn-group-mission-select').after(newWindow);
newWindow = document.createElement("div");
var text = `Einsätze anhand valider PLZ's filtern`;
newWindow.innerHTML = text;
$('#btn-group-mission-select').after(newWindow);
setInterval(
function filterMission(){
from = parseInt(document.getElementById('vonPLZ').value);
to = parseInt(document.getElementById('bisPLZ').value);
var allMissions = document.getElementsByClassName('missionSideBarEntry missionSideBarEntrySearchable');
for(var i = 0; i < allMissions.length; i++){
var place = allMissions[i].getAttribute("search_attribute").search(/\d{5,5}/);
if(!isNaN(from) && !isNaN(to)){
if(place >= 0){
var plz = parseInt(allMissions[i].getAttribute("search_attribute").substring(place,place + 5));
if(from <= plz && plz <= to){
allMissions[i].setAttribute("class", "missionSideBarEntry missionSideBarEntrySearchable");
} else {
allMissions[i].setAttribute("class", "missionSideBarEntry missionSideBarEntrySearchable hidden");
}
} else {
allMissions[i].setAttribute("class", "missionSideBarEntry missionSideBarEntrySearchable hidden");
}
} else {
allMissions[i].setAttribute("class", "missionSideBarEntry missionSideBarEntrySearchable");
}
}
},3000);
}
})();