Average level

Returns the average level of the current chat room

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name           Average level
// @namespace      arreloco
// @description    Returns the average level of the current chat room
// @include        http://www.kongregate.com/games/*
// @version 0.0.1.20160306133113
// ==/UserScript==
function init()
{
	var dom;

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

	var holodeck = dom.holodeck;
	
		//Credit goes partially to Ventero for this command
		holodeck.addChatCommand("average", function(l,n){
			var matchArr = n.match(/^\/\S+\s+(\d+)/),
					userList = l.chatWindow().activeRoom().users(),
					countArr = [];
					
			var total_level = 0;
			var max_level = 0;
			var best_user = "";
			var plus_40_users = [];

			for(var i=0;i<userList.length;i++){
				total_level += userList[i].variables.level;
				if(userList[i].variables.level>max_level){
					best_user = userList[i].variables.username;
					max_level = userList[i].variables.level;
				}
				if(userList[i].variables.level>39){
					plus_40_users.push("\n <a href=\"http://www.kongregate.com/accounts/"+userList[i].variables.username+"\" target=\"_blank\">"+userList[i].variables.username+"</a>");
				}
			}
			
			var average_level = Math.round(total_level/userList.length*10)/10;
			l.activeDialogue().displayUnsanitizedMessage("Kong Bot", "The average level of this room is "+average_level+" and the best user is <a href=\"http://www.kongregate.com/accounts/"+best_user+"/\" target=\"_blank\">"+best_user+"</a> (lvl "+max_level+").", {"class":"whisper received_whisper"}, {non_user: true});
			l.activeDialogue().displayUnsanitizedMessage("Kong Bot", "Here are all the users who are > or equal to 40:"+plus_40_users, {"class":"whisper received_whisper"}, {non_user: true});
			
			return false;
		})
		
		holodeck._chat_commands.media = holodeck._chat_commands.average;
}//end init()

setTimeout(init,0);