-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdata-background-script.js
46 lines (42 loc) · 1.54 KB
/
data-background-script.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
if (typeof browser === 'undefined') { var browser = chrome; }
export async function getWeatherAppData(location) {
try {
let data = await browser.storage.local.get("weatherAppData");
let weatherAppData = data.weatherAppData || {
weatherData: null,
lastUpdateDate: new Date().toISOString(),
lastLocation: location || ""
};
weatherAppData.lastUpdateDate = new Date(weatherAppData.lastUpdateDate).toISOString();
await browser.storage.local.set({
weatherAppData: {
weatherData: weatherAppData.weatherData,
lastUpdateDate: weatherAppData.lastUpdateDate,
lastLocation: weatherAppData.lastLocation
}
});
console.log('Retrieved weather AppData.');
return weatherAppData;
} catch (error) {
console.error('Error retrieving weather AppData:', error);
}
}
export async function getDelijnAppData() {
try {
let data = await browser.storage.local.get("delijnAppData");
let delijnAppData = data.delijnAppData || {
entiteitnummer: null,
haltenummer: null,
};
await browser.storage.local.set({
delijnAppData: {
entiteitnummer: delijnAppData.entiteitnummer,
haltenummer: delijnAppData.haltenummer,
}
});
console.log('Retrieved Delijn AppData.');
return delijnAppData;
} catch (error) {
console.error('Error retrieving Delijn AppData:', error);
}
}