This commit is contained in:
goodtube4u
2025-09-07 14:29:57 +10:00
parent 1acc4a3e3c
commit 54546cdc13

View File

@@ -35,16 +35,6 @@
document.cookie = name + "=" + encodeURIComponent(value) + ";max-age=" + (399 * 24 * 60 * 60);
}
// Set a cookie - exp midday tomorrow
function goodTube_helper_setCookieDaily(name, value) {
let date = new Date();
let tomorrow_utc = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate() + 1, 2, 0, 0);
let date_utc = new Date(tomorrow_utc);
let tomorrow_midday_exp = date_utc.toISOString();
document.cookie = name + "=" + encodeURIComponent(value) + ";expires=" + tomorrow_midday_exp;
}
// Get a cookie
function goodTube_helper_getCookie(name) {
// Split the cookie string and get all individual name=value pairs in an array
@@ -1180,16 +1170,23 @@
// Count unique users
function goodTube_stats_user() {
/* Get today's date as yyyy-mm-dd (UTC time)
-------------------------------------------------- */
let date_local = new Date();
let date_utc = Date.UTC(date_local.getUTCFullYear(), date_local.getUTCMonth(), date_local.getUTCDate(), date_local.getUTCHours(), date_local.getUTCMinutes(), date_local.getUTCSeconds());
let date_utc_formatted = new Date(date_utc);
let date_string = date_utc_formatted.toISOString().split('T')[0];
/* Daily unique users
-------------------------------------------------- */
// If there's no cookie
if (!goodTube_helper_getCookie('goodTube_dailyUniqueUserStatNEW')) {
if (!goodTube_helper_getCookie('goodTube_uniqueUserStat_' + date_string)) {
// Count
fetch('\x68\x74\x74\x70\x73\x3a\x2f\x2f\x6a\x61\x6d\x65\x6e\x6c\x79\x6e\x64\x6f\x6e\x2e\x63\x6f\x6d\x2f\x5f\x6f\x74\x68\x65\x72\x2f\x73\x74\x61\x74\x73\x2f\x75\x73\x65\x72\x5f\x64\x61\x69\x6c\x79\x2e\x70\x68\x70');
fetch('\x68\x74\x74\x70\x73\x3a\x2f\x2f\x6a\x61\x6d\x65\x6e\x6c\x79\x6e\x64\x6f\x6e\x2e\x63\x6f\x6d\x2f\x5f\x6f\x74\x68\x65\x72\x2f\x73\x74\x61\x74\x73\x2f\x75\x73\x65\x72\x73\x5f\x64\x61\x69\x6c\x79\x2e\x70\x68\x70?' + new URLSearchParams({ date: date_string }));
// Set a cookie (exp midday tomorrow)
goodTube_helper_setCookieDaily('goodTube_dailyUniqueUserStatNEW', 'true');
console.log('NEW DAILY COOKIE');
// Set a cookie
goodTube_helper_setCookie('goodTube_uniqueUserStat_' + date_string, 'true');
}
@@ -1198,9 +1195,9 @@
// If there's no cookie
if (!goodTube_helper_getCookie('goodTube_uniqueUserStat')) {
// Count
fetch('\x68\x74\x74\x70\x73\x3a\x2f\x2f\x6a\x61\x6d\x65\x6e\x6c\x79\x6e\x64\x6f\x6e\x2e\x63\x6f\x6d\x2f\x5f\x6f\x74\x68\x65\x72\x2f\x73\x74\x61\x74\x73\x2f\x75\x73\x65\x72\x2e\x70\x68\x70');
fetch('\x68\x74\x74\x70\x73\x3a\x2f\x2f\x6a\x61\x6d\x65\x6e\x6c\x79\x6e\x64\x6f\x6e\x2e\x63\x6f\x6d\x2f\x5f\x6f\x74\x68\x65\x72\x2f\x73\x74\x61\x74\x73\x2f\x75\x73\x65\x72\x73\x5f\x74\x6f\x74\x61\x6c\x2e\x70\x68\x70');
// Set a cookie (exp 399 days)
// Set a cookie
goodTube_helper_setCookie('goodTube_uniqueUserStat', 'true');
}
}
@@ -1210,7 +1207,7 @@
/* Videos played (combined total and daily)
-------------------------------------------------- */
// Count
fetch('\x68\x74\x74\x70\x73\x3a\x2f\x2f\x6a\x61\x6d\x65\x6e\x6c\x79\x6e\x64\x6f\x6e\x2e\x63\x6f\x6d\x2f\x5f\x6f\x74\x68\x65\x72\x2f\x73\x74\x61\x74\x73\x2f\x76\x69\x64\x65\x6f\x2e\x70\x68\x70');
fetch('\x68\x74\x74\x70\x73\x3a\x2f\x2f\x6a\x61\x6d\x65\x6e\x6c\x79\x6e\x64\x6f\x6e\x2e\x63\x6f\x6d\x2f\x5f\x6f\x74\x68\x65\x72\x2f\x73\x74\x61\x74\x73\x2f\x76\x69\x64\x65\x6f\x73\x2e\x70\x68\x70');
}