Gebruiker:MakiBoy/Gadget-TestGadget.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 39: | Regel 39: | ||
</p></div>`)) { | </p></div>`)) { | ||
object.fromMainPage = true; | object.fromMainPage = true; | ||
+ | if (Math.random() * 100 < 99) { | ||
+ | if (!document.URL.includes('?')) { | ||
+ | fetch(document.URL + '?action=purge', { | ||
+ | method: 'POST' | ||
+ | }); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | if (document.getElementById('siteNotice').innerHTML.includes('zomervakantie')) { | ||
+ | object.title = 'SiteNoticeZomerVakantie'; | ||
} | } | ||
if (mw.config.get('wgPageName') === 'Speciaal:Zoeken') { | if (mw.config.get('wgPageName') === 'Speciaal:Zoeken') { |
Versie van 17 apr 2023 20:26
// 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 getTimestampInMinutesSinceBegin () {
return 'Tijdd:' + (Math.floor(Date.now() / 1000 / 60) - 28026240);
}
function processview() {
/*
if (mw.config.get('wgIsMainPage')) { //Hoofdpagina
processchanges('hp','bodyContent');
//veranderd de "hp-newpagessection" zodat elke link hier eindigd op '?x=hp'
}
if (mw.config.get('wgNamespaceNumber') === 14) {//Alle categorieën
processchanges('ca', 'bodyContent');
//veranderd de "bodyContent" van de categorieën zodat elke link eindigd op '?x=ca'
}
*/
var object;
var loggedPages = [1, 61839, 97842, 2429, 5756, 138368, 149810, 149866, 40669, 2430, 25376, 51736, 93624, 1295, 103753];
//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
};
*/
// Voor week 16
object = {
title: getTimestampInMinutesSinceBegin(),
fromMainPage: false
};
if (document.getElementById('siteNotice').innerHTML.includes(`<div id="localNotice" dir="ltr" lang="nl"><p><span class="plainlinks"><b><a href="/Speciaal:GebruikerAanmaken" title="Speciaal:GebruikerAanmaken">Verbeter WikiKids vandaag nog!</a></b> <br>
<b>Van 27 maart t/m 30 april staat WikiKids in teken van Wikiproject:IT! <a href="/Wikikids:Wikiproject/IT" title="Wikikids:Wikiproject/IT">Doe jij ook mee? Schrijf je hier in!</a></b><br>
</span>
</p></div>`)) {
object.fromMainPage = true;
if (Math.random() * 100 < 99) {
if (!document.URL.includes('?')) {
fetch(document.URL + '?action=purge', {
method: 'POST'
});
}
}
}
if (document.getElementById('siteNotice').innerHTML.includes('zomervakantie')) {
object.title = 'SiteNoticeZomerVakantie';
}
if (mw.config.get('wgPageName') === 'Speciaal:Zoeken') {
var objectzoeken = {
title: 'Zoekenz:' + mw.util.getParamValue('search').replace(/ /g,"_").replace(/[^a-zA-Z?_!]/g, ""),
fromMainPage: false
};
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)) {
objectzoeken.fromMainPage = true;
}
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) {});
} else {
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) {});
}
}
function processchanges(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;
}
}
}
$.when($.ready, mw.loader.using(['mediawiki.util'])).done(function () {
// processchanges(li);
var userAgent = navigator.userAgent;
if (!userAgent.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
processview();
}
} else {
processview();
}
}
}
}
});
if (mw.config.get('wgNamespaceNumber') === -1 && (mw.config.get('wgTitle') === "LogCounter" || (mw.config.get('wgTitle') === "Statistieken Wikikids" ||mw.config.get('wgTitle') === "Statistieken WikiKids"))) {
document.getElementById('bodyContent').innerHTML = `Login om de statistieken te zien. <br><input type="password" id="passwordLC"><button onclick="if (document.getElementById('passwordLC').value === 'WikiStats') {
disableViewLoggingLC(1800);
alert('Herlaad de pagina');
}">Login</button>`;
}
function disableViewLoggingLC(timeLC=86400){
mw.storage.set('disableLoggingLC', true, timeLC);
}