Gebruiker:MakiBoy/Gadget-TestGadget.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(fixed) |
|||
Regel 52: | Regel 52: | ||
if (mw.config.get('wgUserEditCount') < 50) { | if (mw.config.get('wgUserEditCount') < 50) { | ||
if (mw.util.getParamValue('x') !== "N") { | if (mw.util.getParamValue('x') !== "N") { | ||
− | process(); | + | if (window.performance) {//controleert of het kan controleren |
+ | if (performance.navigation.type != performance.navigation.TYPE_RELOAD) {//controleert of de pagina niet is herladen | ||
+ | process(); | ||
+ | } | ||
+ | } else { | ||
+ | process(); | ||
+ | } | ||
} | } | ||
} | } | ||
}); | }); |
Versie van 14 jan 2023 01:20
//Script
//parameter x
//waarde hp:
// pagina wordt bezocht vanaf de hoofdpagina
//waarde N:
// paginabezoek wordt niet gelogd
function process() {
if (mw.config.get('wgIsMainPage')) {
//veranderd de "hp-newpagessection" zodat elke link hier eindigd op '?x=h'
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;
}
var loggedPages = [1, 61839, 97842, 2429, 5756, 138368];
if ((mw.config.get('wgArticleId') > 0 && mw.config.get('wgNamespaceNumber') === 0) || (loggedPages.includes(mw.config.get('wgArticleId')))) {
var object = {
title: mw.config.get('wgPageName'),
fromMainPage: false
};
if (mw.util.getParamValue('x') === "hp") {
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.config.get('wgUserEditCount') < 50) {
if (mw.util.getParamValue('x') !== "N") {
if (window.performance) {//controleert of het kan controleren
if (performance.navigation.type != performance.navigation.TYPE_RELOAD) {//controleert of de pagina niet is herladen
process();
}
} else {
process();
}
}
}
});