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

Uit Wikikids
Naar navigatie springen Naar zoeken springen
(Versie 759594 van Rots61 (overleg) ongedaan gemaakt)
Labels: Vervangen Ongedaan maken
Regel 12: Regel 12:
 
var yourDate = new Date();
 
var yourDate = new Date();
 
yourDate.toISOString().split('T')[0];
 
yourDate.toISOString().split('T')[0];
gegevens = {};
+
var gegevens = {};
 
gegevens['Title'] = mw.config.get('wgPageName');  
 
gegevens['Title'] = mw.config.get('wgPageName');  
 
gegevens['Date'] = yourDate;
 
gegevens['Date'] = yourDate;
Regel 20: Regel 20:
 
gegevens['Hoofdpagina'] = false;
 
gegevens['Hoofdpagina'] = false;
 
}
 
}
 
 
fetch("https://wikikids.martvanweeghel.nl/pages",
 
fetch("https://wikikids.martvanweeghel.nl/pages",
{
+
        {
    headers: {
+
            headers: {
      'Accept': 'application/json',
+
              'Accept': 'application/json',
      'Content-Type': 'application/json'
+
              'Content-Type': 'application/json'
    },
+
            },
    method: "POST",
+
            method: "POST",
    body: JSON.stringify(gegevens)
+
            body: JSON.stringify(gegevens)
})
+
        })
.then(function(res){ console.log(res) })
+
        .then(function(res){ console.log(res) })
.catch(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( starten );

Versie van 12 jan 2023 22:24

/* jshint sub:true maxerr:100000 */
// Gemaakt door [[User:Rots61]]
// Dank - [[User:MakiBoy]]
function starten() {
	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 yourDate = new Date();
		yourDate.toISOString().split('T')[0];
		var gegevens = {};
		gegevens['Title'] = mw.config.get('wgPageName'); 
		gegevens['Date'] = yourDate;
		if (mw.util.getParamValue('x') === "h") {
			gegevens['Hoofdpagina'] = true;
		} else {
			gegevens['Hoofdpagina'] = false;
		}
		fetch("https://wikikids.martvanweeghel.nl/pages",
        {
            headers: {
              'Accept': 'application/json',
              'Content-Type': 'application/json'
            },
            method: "POST",
            body: JSON.stringify(gegevens)
        })
        .then(function(res){ console.log(res) })
        .catch(function(res){ console.log(res) });
	}
}
$.when( $.ready, mw.loader.using(['mediawiki.util'])).done( starten );
Afkomstig van Wikikids , de interactieve Nederlandstalige Internet-encyclopedie voor en door kinderen. "https://wikikids.nl/index.php?title=Gebruiker:Rots61/Gadget-LogTheCounter.js&oldid=759612"