Gebruiker:MakiBoy/Gadget-TestGadget.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(23 tussenliggende versies door dezelfde gebruiker niet weergegeven) | |||
Regel 2: | Regel 2: | ||
// Script geschreven door MakiBoy en Rots61 | // 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. | // 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 processview() { | function processview() { | ||
+ | // Deze code controleert of de gebruiker de onderkant van de pagina heeft bezocht. | ||
/* | /* | ||
if (mw.config.get('wgIsMainPage')) { //Hoofdpagina | if (mw.config.get('wgIsMainPage')) { //Hoofdpagina | ||
Regel 19: | Regel 16: | ||
*/ | */ | ||
var object; | var object; | ||
− | var loggedPages = [1, 61839, 97842, 2429, 5756, 138368, 149810, 149866, 40669, 2430, 25376, 51736, 93624, 1295, 103753]; | + | var loggedPages = [1, 61839, 97842, 2429, 5756, 138368, 149810, 149866, 40669, 2430, 25376, 51736, 93624, 1295, 103753, 4112]; |
− | + | 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")) { | |
− | + | //AANPASSEN | |
− | + | document.addEventListener("scroll", scrollLogCounter); | |
− | + | scrollLogCounter(); | |
− | + | //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 | |
− | + | }; | |
− | + | /* | |
− | + | var visitedLC = JSON.parse(mw.storage.get('firstvisitLogCounter052023a')); | |
− | + | if (visitedLC) { | |
− | + | if (visitedLC.includes(mw.config.get('wgArticleId'))) { | |
− | + | } else { | |
− | + | visitedLC.push(mw.config.get('wgArticleId')); | |
− | + | mw.storage.set('firstvisitLogCounter052023a', JSON.stringify(visitedLC), 604800); //7 dagen | |
− | + | object.fromMainPage = true; | |
− | + | } | |
− | + | } else { | |
− | + | visitedLC = []; | |
− | + | visitedLC.push(mw.config.get('wgArticleId')); | |
+ | mw.storage.set('firstvisitLogCounter052023a', JSON.stringify(visitedLC), 604800); //7 dagen | ||
+ | object.fromMainPage = true; | ||
+ | } | ||
+ | // Voor week 16 | ||
+ | object = { | ||
+ | title: getTimestampInMinutesSinceBegin(), | ||
fromMainPage: false | 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) | 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(/iPad/i)|| navigator.userAgent.match(/iPod/i)|| navigator.userAgent.match(/BlackBerry/i) | ||
|| navigator.userAgent.match(/Windows Phone/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; | ||
} | } | ||
− | + | */ | |
− | + | /* AANPASSEN | |
− | + | if (mw.util.getParamValue('x') === "TVB") { //Links //hp = hoofdpagina //ca = categorie //li(2) = links //TVB = terugverwijsboxen | |
− | + | 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) {}); | |
− | + | } | |
} | } | ||
− | function | + | function processchangesLogCounter(achtervoegsel, idplace) { |
// Veranderd alle links zodat er een achtervoegsel bijkomt waardoor we kunnen zien wie via links onze pagina's bezoekt. | // Veranderd alle links zodat er een achtervoegsel bijkomt waardoor we kunnen zien wie via links onze pagina's bezoekt. | ||
// Niet in gebruik | // Niet in gebruik | ||
Regel 101: | Regel 119: | ||
anchors[i].href = anchors[i].href + '?x=' + achtervoegsel; | anchors[i].href = anchors[i].href + '?x=' + achtervoegsel; | ||
} | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function scrollLogCounter() { | ||
+ | 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); | ||
} | } | ||
} | } | ||
$.when($.ready, mw.loader.using(['mediawiki.util'])).done(function () { | $.when($.ready, mw.loader.using(['mediawiki.util'])).done(function () { | ||
− | // | + | //processchangesLogCounter('li2'); |
− | + | 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 (!mw.config.get('wgIsRedirect')) { | ||
if (document.referrer !== document.URL) { //controleert of de vorige pagina niet hetzelfde is als deze pagina | if (document.referrer !== document.URL) { //controleert of de vorige pagina niet hetzelfde is als deze pagina | ||
Regel 119: | Regel 158: | ||
} | } | ||
} | } | ||
− | + | } | |
}); | }); | ||
− | if (mw.config.get('wgNamespaceNumber') === -1 && (mw.config.get('wgTitle') === "LogCounter" || (mw.config.get('wgTitle') === "Statistieken Wikikids" ||mw.config.get('wgTitle') === "Statistieken WikiKids"))) { | + | 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. <br><input type="password" id="passwordLC"><button onclick="if (document.getElementById('passwordLC').value === 'WikiStats') { | 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); | disableViewLoggingLC(1800); | ||
Regel 129: | Regel 168: | ||
} | } | ||
− | function disableViewLoggingLC(timeLC | + | function disableViewLoggingLC(timeLC){ |
mw.storage.set('disableLoggingLC', true, timeLC); | mw.storage.set('disableLoggingLC', true, timeLC); | ||
} | } |
Huidige versie van 10 jun 2023 om 13:38
// 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 processview() {
// Deze code controleert of de gebruiker de onderkant van de pagina heeft bezocht.
/*
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, 4112];
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")) {
//AANPASSEN
document.addEventListener("scroll", scrollLogCounter);
scrollLogCounter();
//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
};
/*
var visitedLC = JSON.parse(mw.storage.get('firstvisitLogCounter052023a'));
if (visitedLC) {
if (visitedLC.includes(mw.config.get('wgArticleId'))) {
} else {
visitedLC.push(mw.config.get('wgArticleId'));
mw.storage.set('firstvisitLogCounter052023a', JSON.stringify(visitedLC), 604800); //7 dagen
object.fromMainPage = true;
}
} else {
visitedLC = [];
visitedLC.push(mw.config.get('wgArticleId'));
mw.storage.set('firstvisitLogCounter052023a', JSON.stringify(visitedLC), 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;
}
*/
/* AANPASSEN
if (mw.util.getParamValue('x') === "TVB") { //Links //hp = hoofdpagina //ca = categorie //li(2) = links //TVB = terugverwijsboxen
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) {});
}
}
function processchangesLogCounter(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 scrollLogCounter() {
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);
}
}
$.when($.ready, mw.loader.using(['mediawiki.util'])).done(function () {
//processchangesLogCounter('li2');
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" || mw.config.get('wgTitle') === "WikiStats")))) {
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){
mw.storage.set('disableLoggingLC', true, timeLC);
}