Benutzer:Jmfayard/monobook.js/deluxehistory.js

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen

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
/*  <pre><nowiki> */

/*************************************************/
// Nom : DeluxeHistory
// Auteur : Dake
// Basé sur du code Ajax de GôTô
// Dernière mise à jour : 8 avril 2006
// Commentaires : 
/*************************************************/
var sysopsDeluxeHistory = null;
var botsDeluxeHistory = null;

function extractUsers(res) {
	pattern = /title\=\"Benutzer:(.*?)\"/g;
	s = "";
	while((result = pattern.exec(res)) != null) {
		s += result[1] + "||";
	}
	return s;
}

/*************************************************/
// Auteur : Dake
// Basé sur du code de GôTô
/*************************************************/
function getBots() {
	try {
		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
	} catch (e) {
	  // mange l'exception
	}

	if (!cookies.get("botsDeluxeHistory")) {
		ajax.conn.onreadystatechange = function () {
			if (ajax.conn.readyState == 4) {
				botsDeluxeHistory = extractUsers(ajax.getResult())
				// conservé pour une semaine
				cookies.setWithDelay("botsDeluxeHistory", botsDeluxeHistory, 1000*3600*24*7)
				getSysops();
			}
		}
		ajax.sendRequest("http://de.wikipedia.org/w/index.php?title=Special:Listusers&group=bot&limit=500&offset=0&action=raw", "GET", true)
	} else {
		botsDeluxeHistory = cookies.get("botsDeluxeHistory")
		getSysops();
	}
}

/*************************************************/
// Auteur : Dake
// Basé sur du code de GôTô
/*************************************************/				
function getSysops() {
	try {
		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
	} catch (e) {
	 // mange l'exception
	}

	if (!cookies.get("sysopsDeluxeHistory")) {
		ajax.conn.onreadystatechange = function () {
			if (ajax.conn.readyState == 4) {
				sysopsDeluxeHistory = extractUsers(ajax.getResult())
				// conservé pour une semaine
				cookies.setWithDelay("sysopsDeluxeHistory", sysopsDeluxeHistory, 1000*3600*24*7)
				deluxeHistoryProcess();
			}
		}
		ajax.sendRequest("http://fr.wikipedia.org/w/index.php?title=Special:Listusers&group=sysop&limit=500&offset=0&action=raw", "GET", true)
	} else {
		sysopsDeluxeHistory = cookies.get("sysopsDeluxeHistory")
		deluxeHistoryProcess();
	}
}
				
// code by Martin Honnen
function getOuterHTML (node) {
	if (node.nodeType == 3)
			return node.nodeValue;
	else if (node.nodeType == 1) {
			var html = '';
		html += '<' + node.nodeName;
		for (var a = 0; a < node.attributes.length; a++)
			html += ' ' + node.attributes[a].nodeName + '="' +
		node.attributes[a].nodeValue + '"';
			if (node.childNodes.length == 0)
			html += ' \/>';
			else {
			html += '>';
			for (var c = 0; c < node.childNodes.length; c++)
			html += getOuterHTML(node.childNodes[c]);
			html += '<\/' + node.nodeName + '>';
		}
			return html;
		}
}
		
function deluxeHistoryProcess() {					
	sysopsList = sysopsDeluxeHistory.split("||")
	botsList = botsDeluxeHistory.split("||")		
	
	var lis = document.getElementById("pagehistory").getElementsByTagName("li");

	for (i=0; i<lis.length; i++) {
		spanNode = lis[i].getElementsByTagName("span");
		username = spanNode[0].childNodes[0].childNodes[0].nodeValue;
		
		// check le statut du contributeur
		var className = "history-user-normal";
		
		// bot ? 
		for (j=0;j<botsList.length;j++) {
			if (botsList[j].indexOf(username)==0) {
				className = "history-user-bot"
				break;
			}
		}  
		
		// sysop ? 
		for (j=0;j<sysopsList.length;j++) {
			if (sysopsList[j].indexOf(username)==0) {
				className = "history-user-sysop"
				break;
			}
		}
	
		// ip ? 
		var ip = /\d{1,3}\.\d{1,3}.\d{1,3}.\d{1,3}/;
		
		if (ip.exec(username)) {
			className = "history-user-ip"
		}
		//lis[i].setAttribute("class", className);
		
		lis[i].innerHTML = "<div class=\"" + className + "\">" + lis[i].innerHTML + "</div>"
		
		inputNodes = lis[i].getElementsByTagName("input");
		for (j=0;j<inputNodes.length;j++) {
			inputNodes[j].style.visibility='visible';
		}

		for (j=0;j<spanNode.length;j++) {
			if(spanNode[j].getAttribute("class")=="history-user") {
				spanNode[j].setAttribute("class", className)
			}
		}
	}
}
					
function deluxeHistoryLoader() {
	if (document.URL.indexOf("&action=history")==-1) return;		
	getBots();
}	

addLoadEvent(deluxeHistoryLoader)	

/* </nowiki></pre> */