-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lockout report.user.js
90 lines (77 loc) · 3.16 KB
/
Lockout report.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// ==UserScript==
// @name Lockout report
// @namespace https://gwg.nz
// @version 0.1.6
// @description Export JSON of lockout report
// @author Mathias Foster
// @match file:///C:/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
if (document.querySelector("body > table > tbody > tr > td:nth-child(2) > table:nth-child(2) > tbody > tr:nth-child(3) > td:nth-child(2) > span").innerText === "Smart Start, Inc. - Separating Drinking from Driving") {
let images = document.querySelectorAll("img");
for (var i in images) {
if (images[i].parentElement) {
images[i].parentElement.removeChild(images[i]);
}
}
let clientNames = [],
installDates = [],
lockoutDates = [],
addresses = [],
tags = [],
driversLicences = [];
let elements = document.querySelectorAll(
"body > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > span"
);
for (var k in elements) {
if (elements[k].innerText === "Client:") {
clientNames.push(
elements[k].parentElement.nextElementSibling.nextElementSibling.innerText
);
} else if (elements[k].innerText === "Install Date:") {
installDates.push(
elements[k].parentElement.nextElementSibling.nextElementSibling.innerText
);
} else if (elements[k].innerText === "In Lockout Since:") {
lockoutDates.push(
elements[k].parentElement.nextElementSibling.nextElementSibling.innerText
);
} else if (elements[k].innerText === "Address:") {
addresses.push(
elements[k].parentElement.nextElementSibling.nextElementSibling.innerText
);
} else if (elements[k].innerText === "Tag:") {
tags.push(
elements[k].parentElement.nextElementSibling.nextElementSibling.innerText
);
} else if (elements[k].innerText === "DL#:") {
driversLicences.push(
elements[k].parentElement.nextElementSibling.nextElementSibling.innerText
);
}
}
let clientInformation = [];
for (var j in clientNames) {
clientInformation.push({
name: clientNames[j],
installDate: installDates[j],
lockoutDate: lockoutDates[j],
address: addresses[j],
tag: tags[j],
driversLicence: driversLicences[j]
});
}
console.log(JSON.stringify(clientInformation));
let req = new XMLHttpRequest();
req.onreadystatechange = () => {
if (req.readyState == XMLHttpRequest.DONE) {
console.log(req.responseText);
}
};
req.open("POST", "https://ss-lockout-report.glitch.me/new", true);
req.setRequestHeader("Content-Type", "application/json");
req.send(JSON.stringify(clientInformation));
}
})();