我正在尝试编写 Google Chrome 应用程序/扩展程序。可悲的是,我对此真的很陌生,并没有发现我正在尝试做的事情是否有可能。
我正在寻找一个 javascript,它通过在控制台中检索特定消息自动点击已知的 HTML 按钮。
背景(如果你现在已经想出了一个解决方案,你就真的不需要这个 - 我只是认为有人可以通过告诉我正在尝试做的事情来了解另一个解决方案的想法。):
我想为名为“vulcun.com”的网站设计机器人。有一个战利品掉落系统,20-30 分钟后会随机出现一个窗口。如果是这样,服务器消息“Lootdrop started”会出现在控制台中。 (参见此处:http://puu.sh/lhRc6/e5813f3748.png)。如果它出现,我想点击“Enter Lootdrop”按钮,它被编码为:
<button type="submit" id="enter-lootdrop" class="button button--submit full-width" value="Login">
Enter Lootdrop
</button>
</div>
我想如果你能帮我解决这个问题,我可以添加其余的(等待和关闭窗口,以及打开新的实时选项卡)。
如果你能帮助我,那就太好了。 我想发布它,这样整个 Vulcun 社区都会感谢你。
我为我糟糕的英语感到抱歉。我学英语的时间不长,用我的母语描述一些我什至难以描述的东西并没有使它变得更好。
真诚的, o菜鸟:)
最佳答案
非常感谢 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 创建一个扩展。但这需要一些时间。
关于javascript - 通过服务器消息单击按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33657314/