Gebruiker:MakiBoy/Gadget-TestGadget.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 1: | Regel 1: | ||
− | //Waarschuwing, heeft impact op | + | //Waarschuwing, heeft impact op alle bezoekers van WikiKids! |
− | //Script | + | //Script geschreven door MakiBoy en Rots61 |
− | |||
− | |||
− | |||
− | |||
function processview() { | function processview() { | ||
+ | // Veranderd alle links zodat er een achtervoegsel bijkomt waardoor we kunnen zien wie via links onze pagina's bezoekt. | ||
+ | var 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=li'; | ||
+ | } | ||
+ | } | ||
/* | /* | ||
if (mw.config.get('wgIsMainPage')) { //Hoofdpagina | if (mw.config.get('wgIsMainPage')) { //Hoofdpagina | ||
Regel 38: | Regel 49: | ||
*/ | */ | ||
var object; | var object; | ||
− | var loggedPages = [1, 61839, 97842, 2429, 5756, 138368, 149810, 149866]; | + | var loggedPages = [1, 61839, 97842, 2429, 5756, 138368, 149810, 149866, 40669, 2430, 25376]; |
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")) { | 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). | //Een bestaande pagina in de naamruimte 0 (artikels), 14 (categorie) of 100 (portaal). | ||
Regel 54: | Regel 65: | ||
} | } | ||
*/ | */ | ||
− | + | if (mw.util.getParamValue('x') === "li") { //Links //hp = hoofdpagina //ca = categorie | |
− | if (mw.util.getParamValue('x') === " | ||
− | |||
− | |||
− | |||
object.fromMainPage = true; | object.fromMainPage = true; | ||
} | } | ||
− | * | + | /* Deze bezoeker is hier gekomen via wikikids. Intern |
− | |||
if ((new RegExp('(://wikikids.nl|://www.wikikids.nl)')).test(document.referrer)) { | if ((new RegExp('(://wikikids.nl|://www.wikikids.nl)')).test(document.referrer)) { | ||
object.fromMainPage = true; | object.fromMainPage = true; | ||
} | } | ||
+ | */ | ||
fetch("https://wikikids.martvanweeghel.nl/pages", | fetch("https://wikikids.martvanweeghel.nl/pages", | ||
{ | { | ||
Regel 79: | Regel 86: | ||
} | } | ||
} | } | ||
+ | |||
$.when($.ready, mw.loader.using(['mediawiki.util'])).done(function () { | $.when($.ready, mw.loader.using(['mediawiki.util'])).done(function () { | ||
if (!mw.storage.get('disableLoggingLC')) { | if (!mw.storage.get('disableLoggingLC')) { | ||
if (mw.config.get('wgUserEditCount') < 5) { | if (mw.config.get('wgUserEditCount') < 5) { | ||
if (!mw.config.get('wgIsRedirect')) { | if (!mw.config.get('wgIsRedirect')) { | ||
− | if (window.performance) {//controleert of het kan controleren | + | if (document.referrer !== document.URL) { //controleerd 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 | |
processview(); | processview(); | ||
} | } | ||
+ | } else { | ||
+ | processview(); | ||
} | } | ||
− | |||
− | |||
} | } | ||
} | } | ||
− | } else { | + | } else { // Als een gebruiker meer dan 5 bewerkingen heeft krijgt hij deze informatie in zijn browser voor 1 dag. Hierdoor kan hij uitgelogd ook geen invloed uitoefenen op de statistieken. |
− | + | disableViewLoggingLC(); | |
} | } | ||
} | } | ||
if (document.getElementById('mw-normal-catlinks')) { | if (document.getElementById('mw-normal-catlinks')) { | ||
− | var | + | var linkscat = document.getElementById('mw-normal-catlinks').getElementsByTagName("a"); |
− | + | linkscat[0].href = '/PIM-systeem'; | |
− | |||
} | } | ||
}); | }); |
Versie van 25 feb 2023 18:58
//Waarschuwing, heeft impact op alle bezoekers van WikiKids!
//Script geschreven door MakiBoy en Rots61
function processview() {
// Veranderd alle links zodat er een achtervoegsel bijkomt waardoor we kunnen zien wie via links onze pagina's bezoekt.
var 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=li';
}
}
/*
if (mw.config.get('wgIsMainPage')) { //Hoofdpagina
//veranderd de "hp-newpagessection" zodat elke link hier eindigd op '?x=hp'
var nps = document.getElementById("hp-newpagessection").innerHTML;
nps = nps.replaceAll('\" title=', '?x=hp\" title=');
document.getElementById("hp-newpagessection").innerHTML = nps;
// "hp-artikel"
var hpa = document.getElementById("hp-artikel").innerHTML;
hpa = hpa.replaceAll('\" title=', '?x=hp\" title=');
document.getElementById("hp-artikel").innerHTML = hpa;
// "hp-portaaloverzicht"
var hppo = document.getElementById("hp-portaaloverzicht").innerHTML;
hppo = hppo.replaceAll('\" title=', '?x=hp\" title=');
document.getElementById("hp-portaaloverzicht").innerHTML = hppo;
// "hp-menu"
var hpm = document.getElementById("hp-menu").innerHTML;
hpm = hpm.replaceAll('\" title=', '?x=hp\" title=');
document.getElementById("hp-menu").innerHTML = hpm;
// "hp-afbeelding"
var hpaf = document.getElementById("hp-afbeelding").innerHTML;
hpaf = hpaf.replaceAll('\" title=', '?x=hp\" title=');
document.getElementById("hp-afbeelding").innerHTML = hpaf;
}
if (mw.config.get('wgNamespaceNumber') === 14) {//Alle categorieën
//veranderd de "bodyContent" van de categorieën zodat elke link eindigd op '?x=ca'
var bcc = document.getElementById("bodyContent").innerHTML;
bcc = bcc.replaceAll('\" title=', '?x=ca\" title=');
document.getElementById("bodyContent").innerHTML = bcc;
}
*/
var object;
var loggedPages = [1, 61839, 97842, 2429, 5756, 138368, 149810, 149866, 40669, 2430, 25376];
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)
object = {
title: mw.config.get('wgPageName'),
fromMainPage: false
};
/* 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 (mw.util.getParamValue('x') === "li") { //Links //hp = hoofdpagina //ca = categorie
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) {});
}
}
$.when($.ready, mw.loader.using(['mediawiki.util'])).done(function () {
if (!mw.storage.get('disableLoggingLC')) {
if (mw.config.get('wgUserEditCount') < 5) {
if (!mw.config.get('wgIsRedirect')) {
if (document.referrer !== document.URL) { //controleerd 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
processview();
}
} else {
processview();
}
}
}
} else { // Als een gebruiker meer dan 5 bewerkingen heeft krijgt hij deze informatie in zijn browser voor 1 dag. Hierdoor kan hij uitgelogd ook geen invloed uitoefenen op de statistieken.
disableViewLoggingLC();
}
}
if (document.getElementById('mw-normal-catlinks')) {
var linkscat = document.getElementById('mw-normal-catlinks').getElementsByTagName("a");
linkscat[0].href = '/PIM-systeem';
}
});
function disableViewLoggingLC (){
mw.storage.set('disableLoggingLC', true, 86400);
}