1

I'm trying to program a Google Chrome App/Extension. Sadly I'm really new to this and didn't find out, if it's even possible what I'm trying to do.

I'm looking for a javascript, that automatically klicks onto a known HTML button by retriving a particular message in the console.

Background (You don't really need this if you already came up with a solution by now - I just thought someone could get the idea of another solution, by telling what I'm trying to do.):

I want to come up with bot for a website named "vulcun.com". There's a loot drop system, by which a window is appearing randomly after 20-30 minutes. If it does the server message "Lootdrop started" appears in the console. (see here: http://puu.sh/lhRc6/e5813f3748.png). If it comes up I want to click the "Enter Lootdrop" button, which is coded as:

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

Enter Lootdrop
</button>
</div> 

I think if you could help me with this one I can add the rest (waiting and closing the windows, aswell as opening up new Live tabs).

Would be nice if you could help me. I want to publish it, so the whole Vulcun community will thank you.

I'm sorry for my horrible English. I'm not learning English for too long and describing something that's even hard for me to describe in my mothertoung doesn't make it better.

Sincerly, oRookie :)

oRookie
  • 265
  • 2
  • 4
  • 13
  • I think you can [inject a script](https://stackoverflow.com/questions/9515704/) that overrides `console.log` function with your own, I've seen some examples. – wOxxOm Nov 11 '15 at 18:38
  • Ehhh... one of us is heading into the wrong way right now. `console.log` is for me to write something into the console, isn't it? How can I catch something, that's written down by the server with it? – oRookie Nov 11 '15 at 19:43
  • Yeah but I'm looking for something to read from the console and start a function, if it's reading the right part. Writing is easy, I guess. Thanks anyways. :) – oRookie Nov 11 '15 at 20:49
  • If you override the `console.log` function then the page script will call your function where you can check the passed parameter whether it contains that message. – wOxxOm Nov 11 '15 at 20:50
  • Ohh now I get it. THANK YOU VERY MUCH! Sorry this was a really advanced thought, but I think I figured it out. That's just brilliant. I can't thank you enough. <3 – oRookie Nov 11 '15 at 20:53
  • Elephant in the room: you can't do it with a Chrome _App_, you normally need an extension to interact with existing web content. – Xan Nov 12 '15 at 01:54

1 Answers1

2

So thanks to wOxxOm, who helped me to come up with the following code:

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;

That's already it. I think I'm just gonna create an Extension for Chrome with this and more helpful stuff on Vulcun. But that's gonna take some time.

oRookie
  • 265
  • 2
  • 4
  • 13