单击按服务器消息的按钮

时间:2015-11-11 18:25:23

标签: javascript html google-chrome google-chrome-extension google-chrome-app

我正在尝试编写Google Chrome应用/扩展程序。可悲的是,我真的很陌生,并没有发现,如果它甚至可能是我想要做的。

我正在寻找一个javascript,它可以通过在控制台中查找特定消息自动点击已知的HTML按钮。

背景(如果你现在已经提出了一个解决方案,你真的不需要这个 - 我只是觉得有人可以通过告诉我要做的事情来了解另一个解决方案。):

我想为一个名为“vulcun.com”的网站提供机器人。有一个战利品掉落系统,在20-30分钟后随机出现一个窗口。如果是,服务器消息“Lootdrop started”出现在控制台中。 (见这里:http://puu.sh/lhRc6/e5813f3748.png)。如果出现,我想点击“输入Lootdrop”按钮,编码为:

<button type="submit" id="enter-lootdrop" class="button button--submit full-width" value="Login">  

Enter Lootdrop
</button>
</div> 

我想如果你可以帮助我这个,我可以添加其余的(等待和关闭窗口,以及打开新的实时标签)。

如果你能帮助我会很好。 我想发布它,所以整个Vulcun社区都会感谢你。

对不起我糟糕的英语。我不会长时间学习英语,并且描述一些甚至难以在我的母语中描述的东西并没有让它变得更好。

诚恳, oRookie:)

1 个答案:

答案 0 :(得分:2)

非常感谢wOxxOm,他帮助我提出了以下代码:

var console=(function(oldCons){
    return {
        log: function(text){
            oldCons.log(text);
        },
        info: function (text) {
            oldCons.info(text);
            if(text == "Lootdrop started"){
                document.getElementById("enter-lootdrop").click();
                oldCons.info("Lootdrop entered");
            }
        },
        warn: function (text) {
            oldCons.warn(text);
        },
        error: function (text) {
            oldCons.error(text);
        }
    };
}(window.console));
window.console = console;

已经是这样了。我想我会在Vulcun上用这个和更有用的东西创建一个Chrome扩展程序。但这需要一些时间。

相关问题