mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-10 03:11:56 +01:00
Update daily users counter (on page)
This commit is contained in:
parent
9106319801
commit
d60adee60e
4 changed files with 24 additions and 11 deletions
|
@ -461,14 +461,22 @@ if (ext_api.webRequest.OnBeforeSendHeadersOptions.hasOwnProperty('EXTRA_HEADERS'
|
|||
extraInfoSpec.push('extraHeaders');
|
||||
|
||||
ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
|
||||
if (details.type === 'main_frame') {
|
||||
let current_date_str = currentDateStr();
|
||||
if (last_date_str < current_date_str) {
|
||||
bpc_count_daily_users(current_date_str);
|
||||
last_date_str = current_date_str;
|
||||
}
|
||||
}
|
||||
|
||||
var requestHeaders = details.requestHeaders;
|
||||
|
||||
var header_referer = '';
|
||||
for (var n in requestHeaders) {
|
||||
if (requestHeaders[n].name.toLowerCase() == 'referer') {
|
||||
header_referer = requestHeaders[n].value;
|
||||
continue;
|
||||
}
|
||||
if (requestHeaders[n].name.toLowerCase() == 'referer') {
|
||||
header_referer = requestHeaders[n].value;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// fix brave browser
|
||||
if (!details.originUrl && !header_referer.includes(details.initiator))
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
var ext_api = (typeof browser === 'object') ? browser : chrome;
|
||||
|
||||
// daily users counter
|
||||
function bpc_count_daily_users() {
|
||||
let date = new Date();
|
||||
let dateStr = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().split("T")[0];
|
||||
function bpc_count_daily_users(dateStr) {
|
||||
ext_api.storage.sync.get({
|
||||
daily_users: {},
|
||||
}, function (items) {
|
||||
|
@ -15,9 +13,16 @@ function bpc_count_daily_users() {
|
|||
}, function () {
|
||||
true;
|
||||
});
|
||||
let count_json = 'https://bitbucket.org/magnolia1234/bpc-firefox-daily-users/downloads/bpc-daily-users-' + dateStr + '.json';
|
||||
let count_json = 'https://bitbucket.org/magnolia1234/bpc-chrome-daily-users/downloads/bpc-daily-users-' + dateStr + '.json';
|
||||
fetch(count_json);
|
||||
}
|
||||
});
|
||||
}
|
||||
bpc_count_daily_users();
|
||||
|
||||
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();
|
||||
bpc_count_daily_users(last_date_str);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"background": {
|
||||
"scripts": ["sites.js", "background.js", "bpc_count_daily_users.js"]
|
||||
"scripts": ["sites.js", "bpc_count_daily_users.js", "background.js"]
|
||||
},
|
||||
"content_security_policy": "script-src 'self'; object-src 'self'",
|
||||
"applications": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"background": {
|
||||
"scripts": ["sites.js", "background.js", "bpc_count_daily_users.js"]
|
||||
"scripts": ["sites.js", "bpc_count_daily_users.js", "background.js"]
|
||||
},
|
||||
"content_security_policy": "script-src 'self'; object-src 'self'",
|
||||
"applications": {
|
||||
|
|
Loading…
Reference in a new issue