Gebruiker:Rots61/JS-Statistieken.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 23: | Regel 23: | ||
//Of een artikel met een ID in de array 'loggedPages'. |
//Of een artikel met een ID in de array 'loggedPages'. |
||
//En alleen als de pagina wordt bekeken (dus niet als het wordt bewerkt of iets anders) |
//En alleen als de pagina wordt bekeken (dus niet als het wordt bewerkt of iets anders) |
||
− | + | ||
$('body').on("click mousedown mouseup focus blur change mousemove mouseover mousewheel keypress touchstart touchmove touchend touchcancel resize scroll select",function(e){ |
$('body').on("click mousedown mouseup focus blur change mousemove mouseover mousewheel keypress touchstart touchmove touchend touchcancel resize scroll select",function(e){ |
||
resetTimeout(); |
resetTimeout(); |
||
}); |
}); |
||
⚫ | |||
⚫ | |||
⚫ | |||
document.addEventListener("scroll", scrollSTS); |
document.addEventListener("scroll", scrollSTS); |
||
scrollSTS(); |
scrollSTS(); |
||
− | + | */ |
|
if (document.getElementById('p-lang')) { |
if (document.getElementById('p-lang')) { |
||
document.getElementById('p-lang').addEventListener("mouseenter", languageLog); |
document.getElementById('p-lang').addEventListener("mouseenter", languageLog); |
||
} |
} |
||
− | + | ||
object = { |
object = { |
||
title: mw.config.get('wgPageName'), |
title: mw.config.get('wgPageName'), |
||
Regel 193: | Regel 194: | ||
*/ |
*/ |
||
} |
} |
||
+ | |||
⚫ | |||
function tijdStatistiekenF () { |
function tijdStatistiekenF () { |
||
if (document.visibilityState !== 'hidden' && timeoutTimerTS !== 0) { |
if (document.visibilityState !== 'hidden' && timeoutTimerTS !== 0) { |
||
Regel 229: | Regel 230: | ||
} |
} |
||
var objecttijd = { |
var objecttijd = { |
||
− | title: 'X:' + secondenTS, |
+ | title: 'X:Z:' + secondenTS, |
fromMainPage: false |
fromMainPage: false |
||
}; |
}; |
||
Regel 249: | Regel 250: | ||
timeoutTimerTS = 30; |
timeoutTimerTS = 30; |
||
} |
} |
||
+ | |||
− | */ |
||
function languageLog() { |
function languageLog() { |
Versie van 24 feb 2024 16:08
// Waarschuwing, heeft impact op alle bezoekers van WikiKids die minder dan 5 bijdragen hebben gedaan!
// Script geschreven door MakiBoy en Rots61
// Een groot gedeelte van de code is een comment, deze code werd eerder gebruikt, en kan later ook gebruikt gaan worden. Verwijder deze code niet.
function processviewSTS() {
/*
if (mw.config.get('wgIsMainPage')) { //Hoofdpagina
processchangesSTS('hp','bodyContent');
//veranderd de "hp-newpagessection" zodat elke link hier eindigd op '?x=hp'
}
if (mw.config.get('wgNamespaceNumber') === 14) {//Alle categorieën
processchangesSTS('ca', 'bodyContent');
//veranderd de "bodyContent" van de categorieën zodat elke link eindigd op '?x=ca'
}
if (mw.config.get('wgIsMainPage')) {
processchangesSTS('hpss', 'hp-snel-aan-de-slag');
}
*/
var object;
var loggedPages = [1, 61839, 97842, 2429, 5756, 138368, 149810, 149866, 40669, 2430, 25376, 51736, 93624, 1295, 103753, 4112, 1445, 151008, 157714, 160016];
if ((mw.config.get('wgArticleId') > 0 && (mw.config.get('wgNamespaceNumber') === 0 || ( mw.config.get('wgNamespaceNumber') === 14) ||mw.config.get('wgNamespaceNumber') === 100)) || (loggedPages.includes(mw.config.get('wgArticleId'))) && (mw.config.get('wgAction') == "view")) {
//Een bestaande pagina in de naamruimte 0 (artikels), 14 (categorie) of 100 (portaal).
//Of een artikel met een ID in de array 'loggedPages'.
//En alleen als de pagina wordt bekeken (dus niet als het wordt bewerkt of iets anders)
$('body').on("click mousedown mouseup focus blur change mousemove mouseover mousewheel keypress touchstart touchmove touchend touchcancel resize scroll select",function(e){
resetTimeout();
});
setInterval(function() {tijdStatistiekenF()}, 1000);
/*
document.addEventListener("scroll", scrollSTS);
scrollSTS();
*/
if (document.getElementById('p-lang')) {
document.getElementById('p-lang').addEventListener("mouseenter", languageLog);
}
object = {
title: mw.config.get('wgPageName'),
fromMainPage: false
};
/*
var offsetStats = new Date().getTimezoneOffset();
if (offsetStats === 180 || offsetStats === 240) {
object.fromMainPage = true;
}
var visitedSTS = JSON.parse(mw.storage.get('visitedWikiStats092023d'));
if (visitedSTS) {
object.fromMainPage = false;
} else {
mw.storage.set('visitedWikiStats092023d', 'true', 604800); //7 dagen
object.fromMainPage = true;
}
var visitedSTS = JSON.parse(mw.storage.get('firstVisitWikiStats072023'));
if (visitedSTS) {
if (visitedSTS.includes(mw.config.get('wgArticleId'))) {
} else {
visitedSTS.push(mw.config.get('wgArticleId'));
mw.storage.set('firstVisitWikiStats072023', JSON.stringify(visitedSTS), 604800); //7 dagen
object.fromMainPage = true;
}
} else {
visitedSTS = [];
visitedSTS.push(mw.config.get('wgArticleId'));
mw.storage.set('firstVisitWikiStats072023', JSON.stringify(visitedSTS), 604800); //7 dagen
object.fromMainPage = true;
}
// Voor week 16
object = {
title: getTimestampInMinutesSinceBegin(),
fromMainPage: false
};
if (window.chrome) { // controleert of de bezoekers Chromium gebruiken.
object.fromMainPage = true;
}
*/
// Detecteert de mobiele telefoon
if (navigator.userAgent.match(/Android/i)|| navigator.userAgent.match(/webOS/i)|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)|| navigator.userAgent.match(/iPod/i)|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)) {
object.fromMainPage = true;
}
/*
if (navigator.userAgent.match(/CRoS/i)) {
object.fromMainPage = true;
}
if (mw.storage.get('firstvisitLogCounter042023a')) {
} else {
mw.storage.set('firstvisitLogCounter042023a', 'waarde', 1209600); //14 dagen,
object.fromMainPage = true;
}
if (mw.util.getParamValue('x') === "TVB") { //Links //hp = hoofdpagina //ca = categorie //li(2) = links //TVB = terugverwijsboxen
object.fromMainPage = true;
}
if (mw.util.getParamValue('x') === "hp") { //hpss = hoofdpaginasnelaandeslag
var objecthp = {
title: 'X:Y:' + mw.config.get('wgPageName'),
fromMainPage: false
};
//verzend stat
}
// Nederlanders en Belgen
if (Intl.DateTimeFormat().resolvedOptions().locale === 'be' || Intl.DateTimeFormat().resolvedOptions().timeZone.includes('/Brus') || Intl.DateTimeFormat().resolvedOptions().locale === 'nl' || Intl.DateTimeFormat().resolvedOptions().timeZone.includes('/Amster')) {
object.fromMainPage = true;
}
// Deze bezoeker is hier gekomen via wikikids. Intern
if ((new RegExp('(://wikikids.nl|://www.wikikids.nl)')).test(document.referrer)) {
object.fromMainPage = true;
}
*/
fetch("https://wikikids.martvanweeghel.nl/pages",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(object)
})
.then(function (res) {})
.catch(function (res) {});
/* if (mw.config.get('wgNamespaceNumber') === 14) {
var object2 = {
title: "X:" + mw.config.get('wgPageName'),
fromMainPage: false
};
if (mw.util.getParamValue('x') === "ca6") {
object2.fromMainPage = true;
}
fetch("https://wikikids.martvanweeghel.nl/pages",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(object2)
})
.then(function (res) {})
.catch(function (res) {});
}
/*
const observerstats = new
PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
if (entry.domInteractive > 5000) {
var objectwalltime = {
title: 'X:domInteractive:' + Math.round(entry.domInteractive/1000) + ':' + Math.round(entry.loadEventEnd/1000) + ':' + mw.config.get('wgPageName'),
fromMainPage: false
};
fetch("https://wikikids.martvanweeghel.nl/pages",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(objectwalltime)
})
.then(function (res) {})
.catch(function (res) {});
}
});
});
observerstats.observe({ type: "navigation", buffered: true });
*/
}
/*
if (mw.config.get('wgPageName') === 'Speciaal:Zoeken') {
var objectzoeken = {
title: 'Zoeken:' + mw.util.getParamValue('search').replace(/ /g,"_").replace(/[^a-zA-Z0-9?_!]/g, "").slice(0,55),
fromMainPage: false
};
fetch("https://wikikids.martvanweeghel.nl/pages",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(objectzoeken)
})
.then(function (res) {})
.catch(function (res) {});
}
*/
}
function tijdStatistiekenF () {
if (document.visibilityState !== 'hidden' && timeoutTimerTS !== 0) {
secondenTS += 1;
timeoutTimerTS -= 1;
if (secondenTS <= 500) {
if ((secondenTS % 20) === 0) {
uploadTS();
}
}
} else if (document.visibilityState === 'hidden') {
resetTimeout();
}
}
function uploadTS () {
var tijdStatistieken = new Date();
if (Math.round(tijdStatistieken.getTime() / 1000) < volgendeStatistieken) {
if ((secondenTS % 500) === 0 & secondenTS > 50) {
var objecttijdextra = {
title: 'X:X' + secondenTS + ':' + mw.config.get('wgPageName'),
fromMainPage: false
};
fetch("https://wikikids.martvanweeghel.nl/pages",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(objecttijdextra)
})
.then(function (res) {})
.catch(function (res) {});
}
var objecttijd = {
title: 'X:Z:' + secondenTS,
fromMainPage: false
};
fetch("https://wikikids.martvanweeghel.nl/pages",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(objecttijd)
})
.then(function (res) {})
.catch(function (res) {});
}
}
function resetTimeout() {
timeoutTimerTS = 30;
}
function languageLog() {
document.getElementById('p-lang').removeEventListener("mouseenter", languageLog);
var objectlanguage = {
title: 'X:Y:' + mw.config.get('wgPageName'),
fromMainPage: false
};
fetch("https://wikikids.martvanweeghel.nl/pages",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(objectlanguage)
})
.then(function (res) {})
.catch(function (res) {});
}
function processchangesSTS(achtervoegsel, idplace) {
// Veranderd alle links zodat er een achtervoegsel bijkomt waardoor we kunnen zien wie via links onze pagina's bezoekt.
// Niet in gebruik
var anchors;
if (idplace) {
if (document.getElementById(idplace)) {
anchors = document.getElementById(idplace).getElementsByTagName("a");
} else {
anchors = document.getElementsByTagName("a");
}
} else {
anchors = document.getElementsByTagName("a");
}
for (var i = 0; i < anchors.length; i++) {
if (anchors[i].hash) {
} else if (anchors[i].href.includes('Gebruiker:')) {
} else if (anchors[i].href.includes('Overleg')) {
} else if (anchors[i].href.includes('index.php')) {
} else if (anchors[i].href.includes('Bestand:')) {
} else if (anchors[i].href.includes('Speciaal:')) {
} else if (anchors[i].href.includes('?')) {
} else if (!anchors[i].href.includes('wikikids')) {
} else {
anchors[i].href = anchors[i].href + '?x=' + achtervoegsel;
}
}
}
function scrollSTS() { //Niet in gebruik
if($(window).scrollTop() + $(window).height() > document.getElementById('bodyContent').clientHeight) {
objectscroll = {
title: mw.config.get('wgPageName'),
fromMainPage: true
};
fetch("https://wikikids.martvanweeghel.nl/pages",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(objectscroll)
})
.then(function (res) {})
.catch(function (res) {});
document.removeEventListener("scroll", scrollLogCounter);
}
}
/*
var secondenTS = 0;
var timeoutTimerTS = 40;
*/
var tijdStatistieken = new Date();
// -> local time op 18:00 voor komende zaterdag, en Epoch timestamp hieronder neerzetten.
//var volgendeStatistieken = 1695916800;
$.when($.ready, mw.loader.using(['mediawiki.util'])).done(function () {
//processchangesSTS('ca6', 'catlinks');
//processchangesSTS('li2');
if (true) { //Math.round(tijdStatistieken.getTime() / 1000) < volgendeStatistieken) { // Zorgt ervoor dat het niet 'doorlekt' naar de volgende statistieken
var userAgentSTS = navigator.userAgent;
if (!userAgentSTS.includes('bot')) { //controleert of de bezoeker een bot is, dan wordt het niet gelogd.
if (!mw.config.get('wgIsRedirect')) {
if (document.referrer !== document.URL) { //controleert of de vorige pagina niet hetzelfde is als deze pagina
if (window.performance) {//controleert of het kan controleren
if (performance.navigation.type != performance.navigation.TYPE_RELOAD) {//controleert of de pagina niet is herladen
processviewSTS();
}
} else {
processviewSTS();
}
}
}
}
}
});
if (mw.config.get('wgNamespaceNumber') === -1 && (mw.config.get('wgTitle') === "LogCounter" || (mw.config.get('wgTitle') === "Statistieken Wikikids" || (mw.config.get('wgTitle') === "Statistieken WikiKids" || mw.config.get('wgTitle') === "WikiStats")))) {
document.getElementById('bodyContent').innerHTML = `Login om de statistieken te zien, als je 5 of meer bijdragen hebt gedaan, kun je de statistieken bekijken zonder wachtwoord. <br><input type="password" id="passwordSTS"><button onclick="if (document.getElementById('passwordSTS').value === 'WikiStats') {
disableViewLoggingSTS(1800);
alert('Herlaad de pagina');
}">Login</button>`;
}
function disableViewLoggingSTS(timeSTS){
mw.storage.set('disableLoggingWS', true, timeSTS);
}