2020-09-06 07:00:36 +00:00
|
|
|
var ext_api = (typeof browser === 'object') ? browser : chrome;
|
|
|
|
|
|
|
|
// daily users counter
|
2020-09-11 14:52:50 +00:00
|
|
|
function bpc_count_daily_users(dateStr) {
|
2020-10-31 19:06:38 +00:00
|
|
|
ext_api.storage.local.get({
|
|
|
|
daily_users: {},
|
|
|
|
}, function (items_local) {
|
|
|
|
daily_users = items_local.daily_users;
|
2020-09-06 07:00:36 +00:00
|
|
|
ext_api.storage.sync.get({
|
|
|
|
daily_users: {},
|
|
|
|
}, function (items) {
|
2020-10-31 19:06:38 +00:00
|
|
|
if (!items_local.daily_users.date)
|
|
|
|
daily_users = items.daily_users;
|
2020-09-06 07:00:36 +00:00
|
|
|
if (daily_users.date !== dateStr) {
|
|
|
|
daily_users.date = dateStr;
|
2020-10-31 19:06:38 +00:00
|
|
|
ext_api.storage.local.set({
|
2020-09-06 07:00:36 +00:00
|
|
|
daily_users: daily_users
|
|
|
|
}, function () {
|
|
|
|
true;
|
|
|
|
});
|
2020-11-25 16:29:48 +00:00
|
|
|
let count_json = 'https://bitbucket.org/bpc_redux/bpc-firefox-daily-users/downloads/bpc-daily-users-' + dateStr + '.json';
|
2020-10-13 15:11:35 +00:00
|
|
|
fetch(count_json, {mode: 'no-cors'});
|
2020-09-06 07:00:36 +00:00
|
|
|
}
|
|
|
|
});
|
2020-10-31 19:06:38 +00:00
|
|
|
});
|
2020-09-06 07:00:36 +00:00
|
|
|
}
|
2020-09-11 14:52:50 +00:00
|
|
|
|
|
|
|
function currentDateStr() {
|
|
|
|
let date = new Date();
|
|
|
|
let dateStr = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().split("T")[0];
|
|
|
|
return dateStr;
|
|
|
|
}
|
|
|
|
var last_date_str = currentDateStr();
|
2020-10-31 19:06:38 +00:00
|
|
|
var daily_users;
|
2020-09-11 14:52:50 +00:00
|
|
|
bpc_count_daily_users(last_date_str);
|