Gebruiker:Rots61/Gadget-LogTheCounter.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(Tekst vervangen door "→jshint sub:true maxerr:100000: // Gemaakt door User:Rots61 if (mw.config.get('wgArticleId') === 0) { var x = document.getElementById("newpagessection").innerHTML...") Label: Vervangen |
|||
Regel 1: | Regel 1: | ||
/* jshint sub:true maxerr:100000 */ | /* jshint sub:true maxerr:100000 */ | ||
// Gemaakt door [[User:Rots61]] | // Gemaakt door [[User:Rots61]] | ||
− | + | console.log(mw.config.get('wgArticleId')); | |
− | if (mw.config.get('wgArticleId') === 0) { | + | function starten() { |
− | + | if (mw.config.get('wgArticleId') === 0) { | |
− | + | var x = document.getElementById("newpagessection").innerHTML; | |
− | + | x = x.replaceAll('\" title=', '?x\" title='); | |
− | + | document.getElementById("newpagessection").innerHTML = x; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | fetch("https://example.com/", | + | if (mw.config.get('wgArticleId') === 149502) { |
− | + | var yourDate = new Date(); | |
− | + | yourDate.toISOString().split('T')[0]; | |
− | + | gegevens = {}; | |
− | + | gegevens['Title'] = mw.config.get('wgPageName'); | |
− | + | gegevens['Date'] = yourDate; | |
− | + | if (mw.util.getParamValue('hp') === "x") { | |
− | + | gegevens['Hoofdpagina'] = true; | |
− | + | } else { | |
− | + | gegevens['Hoofdpagina'] = false; | |
− | + | } | |
+ | |||
+ | fetch("https://example.com/", | ||
+ | { | ||
+ | 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 ); |
Versie van 11 jan 2023 21:57
/* jshint sub:true maxerr:100000 */
// Gemaakt door [[User:Rots61]]
console.log(mw.config.get('wgArticleId'));
function starten() {
if (mw.config.get('wgArticleId') === 0) {
var x = document.getElementById("newpagessection").innerHTML;
x = x.replaceAll('\" title=', '?x\" title=');
document.getElementById("newpagessection").innerHTML = x;
}
if (mw.config.get('wgArticleId') === 149502) {
var yourDate = new Date();
yourDate.toISOString().split('T')[0];
gegevens = {};
gegevens['Title'] = mw.config.get('wgPageName');
gegevens['Date'] = yourDate;
if (mw.util.getParamValue('hp') === "x") {
gegevens['Hoofdpagina'] = true;
} else {
gegevens['Hoofdpagina'] = false;
}
fetch("https://example.com/",
{
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 );