Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
//***********************************************************************
// MARK CVU PROJECT MEMBERS
//***********************************************************************
// siehe [[Benutzer:Xneb20/markCVUnew]]
//***********************************************************************
// markCVUnew.js:
// Skript von [[Benutzer:Xneb20]], unter Verwendung des Originalskripts (siehe unten)
// Einbau und Verwendung: folgende Zeile kopieren:
// mw.loader.load('//de.wikipedia.org/w/index.php?title=Benutzer:Xneb20/markCVUnew.js&action=raw&ctype=text/javascript');
//***********************************************************************
//***********************************************************************
// Credits Orginalskript:
// markAdmins.js:
// Skript ursprünglich von [[Benutzer:Euku]], 28. Dez. 2005
// Ex-Admin-Markierung von [[Benutzer:Sir]] und [[Benutzer:Olliminatore]]
// Adaptierung/zusätzliche Markierungen/Fixes: [[Benutzer:PDD]]
// Aufgeräumt & beschleunigt: [[Benutzer:Littl]]
// Etwas umgeräumt und potentielle Skinabhängigkeit entfernt: [[Benutzer:Guandalug]]
// markMentors.js:
// umgebaut: [[Benutzer:Anka Friedrich]]
// BugFix: [[Benutzer:DerHexer]]
//***********************************************************************
// <nowiki>
// Function to fetch user list from page or retrieve from cache
if (typeof(markcvudebugmode) == 'undefined')
markcvudebugmode = false;
function fetchCVUUserList(callback) {
// Check if user list is stored in local storage and not expired
var cachedCVUUsers = localStorage.getItem('cachedCVUUsers');
var cachedCVUTime = localStorage.getItem('cachedCVUTime');
if (cachedCVUUsers && cachedCVUTime) {
var currentTime = new Date().getTime();
var elapsedTime = currentTime - parseInt(cachedCVUTime);
// Cache expires after 5 days
var cacheDuration = 5 * 24 * 60 * 60 * 1000;
if (elapsedTime < cacheDuration) {
// Use cached user list if it exists and is not empty
var parsedUsers = JSON.parse(cachedCVUUsers);
if (Array.isArray(parsedUsers) && parsedUsers.length > 0) {
//console.log("Using cached user list.");
callback(parsedUsers);
return;
}
}
}
// If cache is expired or not available, fetch from page
var apiUrl = mw.config.get('wgServer') + '/w/api.php?action=parse&format=json&page=Wikipedia:WikiProjekt_Vandalismusbekämpfung/Ansprechpartner';
if (markcvudebugmode) {
console.log("Making API request to: ", apiUrl);
}
jQuery.ajax({
url: apiUrl,
dataType: 'json',
type: 'GET',
success: function (data) {
if (markcvudebugmode) {
console.log("API request successful.");
}
if (data && data.parse && data.parse.links) {
var userList = data.parse.links
.filter(link => (link.ns === 2 && link['*'].startsWith("Benutzer")))
.map(link => encodeURIComponent(link['*'].replace(/Benutzer(in)?:/, "").replace(/ /g, "_")));
// Cache the user list
localStorage.setItem('cachedCVUUsers', JSON.stringify(userList));
localStorage.setItem('cachedCVUTime', new Date().getTime().toString());
callback(userList);
} else {
console.error("Failed to fetch user list from the API.");
callback([]);
}
},
error: function () {
console.error("API request failed.");
callback([]);
}
});
}
function markcvu() {
// Main function to mark CVU users
var wgAction = mw.config.get('wgAction');
var wgNamespaceNumber = mw.config.get('wgNamespaceNumber');
var wgCanonicalNamespace = mw.config.get('wgCanonicalNamespace');
var wgUserName = mw.user.getName();
// Define markmtxt globally
var markmtxt = "CVU";
// Variables that should be defined in your monobook
if (typeof(markcvu) == 'undefined')
markcvu = true;
if (!markcvu)
return; //nichts zu tun, schnell weg hier
if (typeof(markmsubpages) == 'undefined')
markmsubpages = false;
if (typeof(dontmarkmyself) == 'undefined')
dontmarkmyself = true;
if (typeof(isSpecial) == 'undefined')
isSpecial = (wgCanonicalNamespace == "Special");
if (typeof(isHistory) == 'undefined')
isHistory = (wgAction == 'history');
if (typeof(isUserpage) == 'undefined')
isUserpage = ((wgCanonicalNamespace == "User") || (wgCanonicalNamespace == "User_talk"));
if (typeof(isTalk) == 'undefined')
isTalk = (wgNamespaceNumber % 2 == 1);
if (typeof(isProject) == 'undefined')
isProject = (wgCanonicalNamespace == "Project");
if (typeof(isDatei) == 'undefined')
isDatei = (wgCanonicalNamespace == "File");
if (typeof(isHelp) == 'undefined')
isHelp = (wgCanonicalNamespace == "Help");
if (typeof(isDiff) == 'undefined')
isDiff = mw.util.getParamValue('diff') !== null; //Danke an [[Benutzer:TMg]]
// Fetch CVU user list and mark users
fetchCVUUserList(function(cachedCVUUsers) {
if (markcvu) {
if (markcvudebugmode) {
console.log('Cached CVU Users:', cachedCVUUsers);
}
if (isSpecial || isHistory || isUserpage || isTalk || isProject || isDatei || isHelp || isDiff) {
var i;
var mNode;
var allanchors = document.getElementsByTagName("A");
var allanchorsuser = new Array();
var followupmark;
var searchExp = /\/wiki\/Benutzer(in)?([ _]Diskussion)?:(.+)/;
var searchExpTalk = /[ _]Diskussion:/;
var marker;
var mainpageanchor;
mw.util.addCSS('span.cvuMark { font-weight: bold; }');
for (i = 0; i < allanchors.length; i++) {
mNode = allanchors[i];
mainpageanchor = true;
talkpageanchor = false;
// if it's a link to a user
if ((href = mNode.getAttribute("href")) && (searchExp.exec(href) != null)) {
currUser = searchExp.exec(href)[3];
/* if (isUserpage) */ currUserClean = currUser.replace(/\/.*/, '');
if (currUserClean != currUser) mainpageanchor = false;
if (searchExpTalk.exec(href) != null) talkpageanchor = true;
if (mainpageanchor) allanchorsuser[i] = currUserClean;
else allanchorsuser[i] = "";
followupmark = false;
if (i > 0)
if ((currUserClean == allanchorsuser[i - 1]) && talkpageanchor)
followupmark = true;
currUser = currUserClean;
currUserDecoded = decodeURIComponent(currUser);
marker = new Array();
if (markcvudebugmode) {
console.log('+++++ NEW ITEM ++++++');
console.log('Current User:', currUser);
console.log('Current User decoded:', currUserDecoded);
console.log('Is in cached CVU Users: ', cachedCVUUsers.indexOf(currUser) !== -1);
console.log('Is current user (', wgUserName, '): ', currUserDecoded == wgUserName, '; dontmarkmyself: ', dontmarkmyself);
}
if (cachedCVUUsers.indexOf(currUser) !== -1) marker.push(markmtxt);
// don't mark followups
if (!followupmark)
// don't mark certain pages, except link to user main page
if (mainpageanchor ||
(markmsubpages && (wgCanonicalSpecialPageName != "Prefixindex") &&
(wgCanonicalSpecialPageName != "Allpages"))) {
// check finished, now append node
if ((marker.length > 0) && !(dontmarkmyself && (currUserDecoded == wgUserName))) {
var mMark = document.createElement("span");
mMark.className = "cvuMark";
var mMarkText = document.createTextNode(" (" + marker.join("/") + ")");
mMark.appendChild(mMarkText);
mNode.appendChild(mMark);
}
}
}
}
}
}
});
}
jQuery(document).ready(markcvu);
// </nowiki>