-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage_runner.js
More file actions
26 lines (21 loc) · 820 Bytes
/
page_runner.js
File metadata and controls
26 lines (21 loc) · 820 Bytes
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
//Init the counter
init();
//Get counter data and init counting
async function init(){
let currentTotalCount = await getFromStorage("total_count", 0);
let currentTodayCount = await getFromStorage("today_count", 0);
let todayDate = await getFromStorage("today_date", getDateStamp());
let currentMonthCount = await getFromStorage(`month_${getMonthName()}_count`, 0);
if(todayDate!=getDateStamp()){
currentTodayCount = 0;
setToStorage("today_date", getDateStamp());
}
setToStorage("total_count", currentTotalCount+1);
setToStorage("today_count", currentTodayCount+1);
setToStorage(`month_${getMonthName()}_count`, currentMonthCount+1);
//console.log(getDateStamp() + "----" + todayDate);
}
//On error
function onError(){
console.log("storage local error");
}