My userscript does not work [closed]

-4

I am doing a greasemonkey script but my code does not work, I do not know if it is my browser, but if you find some error please correct it.

// ==UserScript==
// @name        ---
// @namespace   ---
// @description ---
// @author      ---
// @match       http://agar.io/*
// @version     1
// @grant       none
// ==/UserScript==

document.getElementsByClassName("btn btn-play btn-primary btn-needs-server")[0].innerHTML = "Jogar";
document.getElementsByClassName("btn btn-primary btn-success btn-freecoins")[0].innerHTML = "Moedas Grátis";
document.getElementsByClassName("btn btn-primary btn-shop")[0].innerHTML = "Loja";
document.getElementsByClassName("btn btn-warning btn-spectate btn-needs-server")[0].innerHTML = "Assistir";
document.getElementsByClassName("btn btn-danger btn-logout")[0].innerHTML = "Desconectar";
document.getElementsByClassName("btn btn-play-guest btn-success btn-needs-server")[0].innerHTML = "Jogar sem Conta";
document.getElementsByClassName("btn btn-warning btn-login-play btn-needs-server")[0].innerHTML = "Conectar";
document.getElementsByClassName("btn-text")[0].innerHTML = "Conectar com Facebook";
document.getElementsByClassName("btn-text")[1].innerHTML = "Conectar com Google";
document.getElementsByClassName("outlined-text")[0].innerHTML = "Conectando...";
document.getElementsByClassName("btn btn-info btn-copy-token copy-party-token")[0].innerHTML = "Copiar";
document.getElementById("create-party-btn").innerHTML = "Criar";
document.getElementById("joinPartyToken").placeholder = "Token da Party";
document.getElementById("join-party-btn").innerHTML = "Entrar";
document.getElementsByClassName("btn-donate")[0].innerHTML = "Doar por clique [Anúncio]";
document.getElementById("skin").placeholder = "URL da Skin (link direto)";
document.getElementById("clantag").placeholder = "TAG";

setInterval(repeat, 500);
function repeat{
    if (document.getElementsByClassName("agario-profile-name")[0].innerHTML == "Guest"){
        document.getElementsByClassName("agario-profile-name")[0].innerHTML = "Convidado";
    }
}

It opens the agar.io with the script of szymy (Ogar.io) and translates to Portuguese, but it does not work

    
asked by anonymous 11.08.2016 / 03:35

2 answers

0

You typed the wrong function, the () relatives:

function repeat{
    if (document.getElementsByClassName("agario-profile-name")[0].innerHTML == "Guest"){
        document.getElementsByClassName("agario-profile-name")[0].innerHTML = "Convidado";
    }
}

The correct one is:

function repeat() {
    if (document.getElementsByClassName("agario-profile-name")[0].innerHTML == "Guest"){
        document.getElementsByClassName("agario-profile-name")[0].innerHTML = "Convidado";
    }
}
    
12.08.2016 / 05:47
0

The main problem is that you are looking for elements across multiple classes in a direct way using document.getElementsByClassName . Use document.querySelector instead of this method.

And instead of using setInterval you can use requestAnimFrame implemented in Agar.io code (yes, it is global):

requestAnimFrame(function repeat() {

    /* Mudanças nesse bloco */

    requestAnimFrame(repeat);

});

But I do not know if updating the HTML of the game with an interval is the most efficient way, but the game code is a bit obfuscated and so it's hard to figure this out ...

    
11.08.2016 / 03:54