Chat Level

Shows average user level beside the room name

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name           Chat Level
// @namespace      arreloco
// @description    Shows average user level beside the room name
// @include        http://www.kongregate.com/games/*
// @version 0.0.1.20160322221006
// ==/UserScript==

function chupala(){
	var dom;

	try{
		if(unsafeWindow){
			dom = unsafeWindow;
		} else {
			dom = this;
		}
	}catch(e){
		dom = this;
	}

	var holodeck = dom.holodeck;
	actual_room = holodeck.chatWindow().activeRoom().name();
	userList = holodeck.chatWindow().activeRoom().users();
	var total_level = 0;
	var max_level = 0;
	for(var i=0;i<userList.length;i++){
		total_level += userList[i].variables.level;
	}
	var average_level = Math.round(total_level/userList.length*10)/10;
	var secondTab = document.getElementById("chat_tab_pane").lastElementChild.style.display;
	if(secondTab != "none"){		document.getElementById("chat_tab_pane").lastChild.firstElementChild.innerHTML = "Room: <span class='room_name'>"+actual_room+"</span><span style='float: right;'>Avg lvl: "+average_level+"</span>";
	}else{		document.getElementById("chat_tab_pane").lastChild.previousSibling.firstElementChild.innerHTML = "Room: <span class='room_name'>"+actual_room+"</span><span style='float: right;'>Avg lvl: "+average_level+"</span>";
	}
}
setInterval(chupala,15000);