-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
61 lines (54 loc) · 1.64 KB
/
index.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
// Get match info:
const status = document.querySelector("#match-detail__status").textContent
const home = document.querySelector("#match-detail__team-name__home").textContent
const away = document.querySelector("#match-detail__team-name__away").textContent
const homeScore = document.querySelector("#match-detail__home__score").textContent
const awayScore = document.querySelector("#match-detail__away__score").textContent
let i = 7;
let j = 7;
const match = {
idMatch: "m" + i,
home: home,
away: away,
status: status,
homeScore: homeScore,
awayScore: awayScore,
details: "dt" + j
}
console.log(JSON.stringify(match));
//Get raw match details
let eventList = []
document.querySelectorAll(".Details_matchRowWrapper__238ut").forEach(detail => {
let e = {
type: "",
assist: null,
team: "",
time: "",
player: ""
}
// Set time for event:
e.time = detail.firstChild.textContent
// Left child
let left = detail.childNodes[1]
leftLen = left.childNodes.length
if (left.firstChild.textContent !== "") {
e.player = left.firstChild.textContent;
e.team = "home"
if (leftLen === 2) {
e.assist = left.lastChild.textContent
e.type = "goal";
}
}
let right = detail.lastChild;
rightLen = right.childNodes.length;
if (right.firstChild.textContent !== "") {
e.player = right.firstChild.textContent;
e.team = "away"
if (rightLen === 2) {
e.assist = right.lastChild.textContent
e.type = "goal";
}
}
eventList.push(e)
})
console.log(JSON.stringify(eventList));