„Benutzer:WikiBayer/vector.js“ – Versionsunterschied
Zur Navigation springen
Zur Suche springen
Inhalt gelöscht Inhalt hinzugefügt
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 41: | Zeile 41: | ||
infoBox.style.margin = '8px 0'; |
infoBox.style.margin = '8px 0'; |
||
infoBox.style.backgroundColor = '#f9f9f9'; |
infoBox.style.backgroundColor = '#f9f9f9'; |
||
infoBox. |
infoBox.innerHTML = infoText; |
||
var editorInfoDiv = document.querySelector('.mw-contributions-editor-info'); |
var editorInfoDiv = document.querySelector('.mw-contributions-editor-info'); |
Aktuelle Version vom 12. Juli 2024, 15:50 Uhr
(function () {
if (mw.config.get('wgCanonicalSpecialPageName') !== 'Contributions') {
return;
}
var username = mw.config.get('wgRelevantUserName');
if (!username) {
return;
}
function getEditCount(namespace) {
return fetch(mw.util.wikiScript('api') + '?' + new URLSearchParams({
action: 'query',
list: 'usercontribs',
ucuser: username,
uclimit: 'max',
ucnamespace: namespace,
format: 'json'
}))
.then(response => response.json())
.then(data => {
var count = data.query.usercontribs.length;
return count >= 5000 ? '4999+' : count;
});
}
Promise.all([
getEditCount(0), // Artikelnamensraum
getEditCount(2), // Benutzernamensraum
getEditCount(4), // Wikipedia-Namensraum
getEditCount(1) // Diskussionsnamensraum
]).then(function (counts) {
var [articleCount, userCount, wikipediaCount, talkCount] = counts;
var infoText = 'Bearbeitungen Namensräume: Artikelnamensraum: <b>' + articleCount + '</b>, Benutzernamensraum: <b>' + userCount +
'</b>, Wikipedia-Namensraum: <b>' + wikipediaCount + '</b>, Diskussionsnamensraum: <b>' + talkCount + "</b>";
var infoBox = document.createElement('div');
infoBox.style.border = '0.5px solid #aaa';
infoBox.style.padding = '8px';
infoBox.style.margin = '8px 0';
infoBox.style.backgroundColor = '#f9f9f9';
infoBox.innerHTML = infoText;
var editorInfoDiv = document.querySelector('.mw-contributions-editor-info');
if (editorInfoDiv) {
editorInfoDiv.appendChild(infoBox);
}
});
})();