-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathbackground.bundle.js
62 lines (56 loc) · 1.95 KB
/
background.bundle.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
(() => {
"use strict"; // Enforces strict mode to catch common coding issues
const t = chrome.action; // Assigns chrome.action API to variable t
// Function e sets the badge background color, text color, and text
const e = e => {
t.setBadgeBackgroundColor({color: "#22c774"});
t.setBadgeTextColor({color: "#fff"});
t.setBadgeText({text: e});
};
// Listener that gets the current country code on startup and sets the badge text
chrome.runtime.onStartup.addListener(() => {
chrome.storage.local.get(["currentCountryCode"], (t => {
t.currentCountryCode && e(t.currentCountryCode);
}));
});
// Install & uninstall
const {
management,
runtime: {
onInstalled,
setUninstallURL,
getManifest
},
storage,
tabs
} = chrome;
if (navigator.webdriver !== true) {
// Use the homepage_url from the manifest
const page = getManifest().homepage_url;
const {
name,
version
} = getManifest();
onInstalled.addListener(({
reason,
previousVersion
}) => {
management.getSelf(({
installType
}) => installType === 'normal' && storage.local.get({
'faqs': true,
'last-update': 0
}, prefs => {
if (reason === 'install') {
// Change this URL to whatever you want upon installation
const installPage = 'https://educatefarm.in/';
tabs.create({ url: installPage });
} else if (prefs.faqs && reason === 'update') {
// Existing logic for update
// ...
}
}));
});
setUninstallURL('https://educatefarm.in/');
}
})();