-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
42 lines (38 loc) · 1.18 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
const studentAttendance = "https://niet.instituteoncloud.com/";
const renderAttendanceDisplayLink =
"https://niet.instituteoncloud.com/AttendanceReport/GetAcademicSemster";
// execute on every tab change
chrome.tabs.onActivated.addListener(async function (activeInfo) {
chrome.tabs.query(
{ active: true, currentWindow: true },
async function (tab) {
console.log(tab);
// check if the tab is the NIET ERP page
if (tab[0].url.startsWith(studentAttendance)) {
// set the title and badge
chrome.action.setTitle({ title: "NIET ERP Page: Attendance Visible" });
chrome.action.setBadgeText({
text: "ERP",
});
chrome.action.setBadgeBackgroundColor({ color: "#ffde59" });
} else {
// reset the title and badge
chrome.action.setBadgeText({
text: "",
});
chrome.action.setTitle({ title: "NIET Attendance: Not ERP Page" });
}
}
);
});
// setup on install
chrome.runtime.onInstalled.addListener(({ reason }) => {
if (reason === "install") {
chrome.action.setBadgeText({
text: "NIET",
});
chrome.tabs.create({
url: "onboarding.html",
});
}
});