-
Notifications
You must be signed in to change notification settings - Fork 1
/
get-live.js
53 lines (44 loc) · 1.75 KB
/
get-live.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
//Trigger app
function trigger_goal(conscise, obj)
{
if (conscise.length > 0) {
// console.log('yes')
// console.log(conscise, obj)
let goalBack = $('<div class="goalBack" />')
let goalContain = $('<div class="goalContain" />')
let goal = $('<div class="goal">GOAL!!!</div>');
let recordTable = $('<table class="recordTable" />')
goalContain.append(goal)
for(let index in conscise)
{
recordTable.append(`<tr><td>${obj.teams[(conscise[index].home_team - 1)].name}</td> <td>${obj.teams[(conscise[index].away_team - 1)].name}</td></tr>`)
recordTable.append(`<tr><td><img class="flag" src="${obj.teams[(conscise[index].home_team - 1)].flag}" /></td> <td><img class="flag" src="${obj.teams[(conscise[index].away_team - 1)].flag}" /></td></tr>`)
recordTable.append(`<tr><td>${conscise[index].home_result}</td> <td>${conscise[index].away_result}</td></tr>`)
// console.log(`${obj.teams[(conscise[index].home_team - 1)].name} ${obj.teams[(conscise[index].away_team - 1)].name}`, `${conscise[index].home_result} ${conscise[index].away_result}`)
}
goalContain.append(recordTable)
// console.log(conscise.length)
goalBack.append(goalContain)
goalBack.click(function () {
$(this).fadeOut(function () {
$(this).remove()
})
})
//Remove any existing .goalBack Element
$("body .goalBack").remove()
$('body').append(goalBack)
}
}
setInterval(
function()
{
chrome.storage.local.get('new_event', function (data) {
new_event = data.new_event
// console.log(new_event)
chrome.storage.local.get('mson', function (data) {
mson = data.mson
// console.log(mson)
trigger_goal(new_event, mson)
})
})
},500);