Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Nov 2012
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Trying to click multiple times using script and console

    Code:
    var x = document.getElementsByName("clickhere"); for (var i = 0; i < 9999999; i++) {x.click();}
    I'm trying to 'cheat' [just to see it work] on this 'click-as-many-times-in-ten-seconds' website: http://www.brainbashers.com/10seconds.asp


    What am I doing wrong?
    I mean, I know I am because it isn't working. Is there a workable solution?
    \Thanks
    Last edited by jerdev; 06-03-2013 at 10:00 AM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,732
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    You can probably guess that it is not possible to simulate clicks. Security, you know. Also to prevent dishonest people from automating click-throughs.


    It is your responsibility to die() if necessary….. - PHP Manual

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by jerdev View Post
    Code:
    var x = document.getElementsByName("clickhere"); for (var i = 0; i < 9999999; i++) {x.click();}
    document.getElementsByName returns a collection not an element.

    You should use x = document.getElementsByName( 'clickhere' )[0];

    But ID should really be used: x = document.getElementById( 'clickhere' );

    The trouble is that code is reading mouseup events, not click.

    Just paste this into the address bar javascript: for( i=0; i<10000; i++){ clickit(); }

    Of course you could bypass the actual count and just record a fake high score on their server by navigating to:
    http://www.brainbashers.com/10second...e=100000000000

  • Users who have thanked Logic Ali for this post:

    jerdev (06-03-2013)

  • #4
    New Coder
    Join Date
    Nov 2012
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Logic Ali View Post
    document.getElementsByName returns a collection not an element.

    You should use x = document.getElementsByName( 'clickhere' )[0];

    But ID should really be used: x = document.getElementById( 'clickhere' );

    The trouble is that code is reading mouseup events, not click.

    Just paste this into the address bar javascript: for( i=0; i<10000; i++){ clickit(); }

    Of course you could bypass the actual count and just record a fake high score on their server by navigating to:
    http://www.brainbashers.com/10second...e=100000000000
    How come that simple code of yours worked?
    I thought we would have to tell javascript what button to press [or at least mouseup] before trying to do the for loop

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Quote Originally Posted by jerdev View Post
    How come that simple code of yours worked?
    I thought we would have to tell javascript what button to press [or at least mouseup] before trying to do the for loop
    Why?

    Look at the (horribly simple-minded) code:
    Code:
    <img src="/gifs/clickhere.gif" name="clickhere" id="clickhere"
         onmouseup="clickit();return false;" 
         width=400 height=400 border=1>
    First of all, the return false is totally unnecessary here.

    So all that is really happening is that every time that <img> tag sees a "mouseup" it calls the function clickit().

    And that being the case, you can emulate the mouseup by, of course, calling clickit() yourself.

    Besides the ways that LogicAli noted, you could also simply do
    Code:
    javascript: lcclicked=81737811; clickit();
    Yes, it works. I tested it. Or you can do it the other way around:
    Code:
    javascript: clickit( ); lcclicked=917181188;
    You have to call clickit() once to get their timer to start working, but you can then just set the number of clicks to anything you want.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Heh! And try doing
    Code:
    javascript: clickit( ); lcclicked = - 731811004; // negative number!
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •