-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbackground.js
52 lines (46 loc) · 2.32 KB
/
background.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
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.type === "covid") {
$.ajax({
url: "https://www.rit.edu/ready/dashboard",
dataType: "text",
success: (data) => {
const level = $(data)
.find("#pandemic-message-container > div > div > a")
.text();
const recentStudent = $(data)
.find(
"#block-rit-bootstrap-subtheme-content > div.field.field--name-field-content.field--type-entity-reference-revisions.field--label-hidden.field__items > div:nth-child(2) > div > div > div > div.row > div > div:nth-child(2) > div > div > div > div > div.col-12.col-md-6.col-statistic.col-statistic-2.item-1.odd > div > p"
)
.text()
.trim();
const recentStaff = $(data)
.find(
"#block-rit-bootstrap-subtheme-content > div.field.field--name-field-content.field--type-entity-reference-revisions.field--label-hidden.field__items > div:nth-child(2) > div > div > div > div.row > div > div:nth-child(2) > div > div > div > div > div.col-12.col-md-6.col-statistic.col-statistic-2.item-2.even.row-end-sm.row-end-lg > div > p"
)
.text()
.trim();
const totalStudent = $(data)
.find(
"#block-rit-bootstrap-subtheme-content > div.field.field--name-field-content.field--type-entity-reference-revisions.field--label-hidden.field__items > div:nth-child(2) > div > div > div > div.row > div > div:nth-child(4) > div > div > div > div > div.col-12.col-md-6.col-statistic.col-statistic-2.item-1.odd > div > p"
)
.text()
.trim();
const totalStaff = $(data)
.find(
"#block-rit-bootstrap-subtheme-content > div.field.field--name-field-content.field--type-entity-reference-revisions.field--label-hidden.field__items > div:nth-child(2) > div > div > div > div.row > div > div:nth-child(4) > div > div > div > div > div.col-12.col-md-6.col-statistic.col-statistic-2.item-2.even.row-end-sm.row-end-lg > div > p"
)
.text()
.trim();
sendResponse({
level,
recentStudent,
recentStaff,
totalStudent,
totalStaff,
});
},
});
// This keeps the message channel open until we call sendResponse
return true;
}
});