sorrisosrs / Fake account

// ==UserScript==
// @name       	Fake account
// @version    	0.1.85
// @include     http://*.tribalwars.*
// @copyright	2014+, You
// @author		Wesley Nascimento
// ==/UserScript==

/* CONFIGURAÇÔES*/
var SAVE_REF = true; //Salvar referencias de jogadores?
var PREFIX = "main-sor"; //Prefixo de referencias para o banco de dados
var DEFAULT_PASS = "defaultPass"; //Senha padrão para as proximas contas
var USE_NICK_PASS = false; // Usar nick no meio da senha?
var WORLD_ID = "server_ptc1"; //Identificação do servidor a ser criado a conta

(function(){   
    
    var loc = location.href;
    
    //http://ptc1.tribalwars.com.pt/game.php?village=10958&mode=ref&source=settings_menu&screen=settings
    //Se etiver na tela de registo pro referencia
    if( StringHas( loc, "ref=player_invite_linkrl") ){
        var nick = getRandomNickName();
        $("#name").val( nick );
        $("#password").val( getPass( nick ) );
        $("#password_confirm").val( getPass( nick ) );
        $("#email").val( getRandomEmailForNick( nick ) );
        $("#agb").click();
        
        if( $("#recaptcha_challenge_image").length == 0 ){
        	$("#register_button").click();
        }
    }
    //Se estiver na tela principal e tiver um botão pra login.
    else if( $("#active_server").length > 0){
        Index.submit_login( WORLD_ID );
    }
    //Se entrar in-game
    else if( StringHas( loc, "screen=overview") ){
            location.href = "/game.php?mode=ref&source=settings_menu&screen=settings";
        }
    //Se estiver na tela de Ref
    else if( $("#ref_link_input").length > 0) {
    	var $ref = $("#ref_link_input");
            
        if( SAVE_REF ){
        	saveRef( $ref.val() );
            
        }        
        getRef();
     }
})();

function StringHas( string , search){ if( string.indexOf( search )  > -1 ){ return true;  } return false; }

function getRef(){
	var url = "http://wesleynascimento.net/cross-domain/tw.class.php?callback=?&get";
    $.getJSON(url, {prefix: PREFIX }, function( result ){    
    	var data = result.data[0];
        location.href = data.ref;
    });
}

function saveRef( ref ){     
    var url = "http://wesleynascimento.net/cross-domain/tw.class.php?callback=?&set";
    $.getJSON(url, {prefix: PREFIX, ref : ref });
}

function getPass( nickname ){
    return USE_NICK_PASS ? DEFAULT_PASS + nickname : DEFAULT_PASS;
};

function getRandomEmailForNick( nickname ){
    var emails = ["hotmail.com", "hotmail.com.br", "outlook.com.br", "yahoo.com.br", "yahoo.com", "outlook.com"];
    var rand = Math.floor( (Math.random() * emails.length) );
    return nickname + "@" + emails[ rand ];
}

function getRandomNickName(){
    var startNames = ["guest", "convidado", "viadinho", "gayzinho"];
    
    var rand = Math.floor( (Math.random() * startNames.length) );  
    
    return Math.random().toString(36).replace(/[^A-Za-z0-9]+/g, '').substr(0, 18);
}