Gebruiker:Rots61/Gadget-LogTheCounter.js: verschil tussen versies

Uit Wikikids
Naar navigatie springen Naar zoeken springen
Regel 1: Regel 1:
 
/* jshint sub:true maxerr:100000 */
 
/* jshint sub:true maxerr:100000 */
// Gemaakt door [[User:Rots61]]
+
// Gemaakt door [[User:MakiBoy]] en [[User:Rots61]]
// Dank - [[User:MakiBoy]]
+
 
function starten() {
+
function process() {
if (mw.config.get('wgArticleId') === 1) {
+
    if (mw.config.get('wgArticleId') === 1) {
var x = document.getElementById("newpagessection").innerHTML;
+
        var x = document.getElementById("newpagessection").innerHTML;
x = x.replaceAll('\" title=', '?x=h\" title=');
+
        x = x.replaceAll('\" title=', '?x=h\" title=');
document.getElementById("newpagessection").innerHTML = x;
+
        document.getElementById("newpagessection").innerHTML = x;
}
+
    }
var loggedpages = [149502, 149477];
+
 
if (loggedpages.includes(mw.config.get('wgArticleId'))) {
+
    var loggedPages = [149502, 149477];
var yourDate = new Date();
+
 
yourDate.toISOString().split('T')[0];
+
    if (loggedPages.includes(mw.config.get('wgArticleId'))) {
var gegevens = {};
+
        var object = {
gegevens['title'] = mw.config.get('wgPageName');
+
            title: mw.config.get('wgPageName'),
gegevens['date'] = yourDate;
+
            date: new Date().toISOString().split('T')[0],
if (mw.util.getParamValue('x') === "h") {
+
            fromMainPage: false
gegevens['fromMainPage'] = true;
+
        };
} else {
+
 
gegevens['fromMainPage'] = false;
+
        if (mw.util.getParamValue('x') === "h") {
}
+
            object.fromMainPage = true;
console.log(gegevens);
+
        }
fetch("https://wikikids.martvanweeghel.nl/pages",
+
 
        {
+
        console.log(object);
            headers: {
+
        fetch("https://wikikids.martvanweeghel.nl/pages",
              'Accept': 'application/json',
+
            {
              'Content-Type': 'application/json'
+
                headers: {
            },
+
                    'Accept': 'application/json',
            method: "POST",
+
                    'Content-Type': 'application/json'
            body: JSON.stringify(gegevens)
+
                },
        })
+
                method: "POST",
        .then(function(res){ console.log(res) })
+
                body: JSON.stringify(object)
        .catch(function(res){ console.log(res) });
+
            })
}
+
            .then(function (res) { console.log(res); })
 +
            .catch(function (res) { console.log(res); });
 +
    }
 
}
 
}
$.when( $.ready, mw.loader.using(['mediawiki.util'])).done( starten );
+
$.when($.ready, mw.loader.using(['mediawiki.util'])).done(process);

Versie van 12 jan 2023 22:36

/* jshint sub:true maxerr:100000 */
// Gemaakt door [[User:MakiBoy]] en [[User:Rots61]]

function process() {
    if (mw.config.get('wgArticleId') === 1) {
        var x = document.getElementById("newpagessection").innerHTML;
        x = x.replaceAll('\" title=', '?x=h\" title=');
        document.getElementById("newpagessection").innerHTML = x;
    }

    var loggedPages = [149502, 149477];

    if (loggedPages.includes(mw.config.get('wgArticleId'))) {
        var object = {
            title: mw.config.get('wgPageName'),
            date: new Date().toISOString().split('T')[0],
            fromMainPage: false
        };

        if (mw.util.getParamValue('x') === "h") {
            object.fromMainPage = true;
        }

        console.log(object);
        fetch("https://wikikids.martvanweeghel.nl/pages",
            {
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                method: "POST",
                body: JSON.stringify(object)
            })
            .then(function (res) { console.log(res); })
            .catch(function (res) { console.log(res); });
    }
}
$.when($.ready, mw.loader.using(['mediawiki.util'])).done(process);
Afkomstig van Wikikids , de interactieve Nederlandstalige Internet-encyclopedie voor en door kinderen. "https://wikikids.nl/index.php?title=Gebruiker:Rots61/Gadget-LogTheCounter.js&oldid=759621"