1. This website uses cookies to improve service and provide a tailored user experience. By using this site, you agree to this use. See our Cookie Policy.
    Dismiss Notice

Greasemonkey script to click a button

Discussion in 'Scripting' started by Scorpion Ghost, Sep 10, 2019.

  1. Scorpion Ghost

    Scorpion Ghost Jr. VIP Jr. VIP

    Joined:
    Mar 22, 2013
    Messages:
    2,814
    Likes Received:
    1,094
    Occupation:
    Internet!
    Location:
    On the Interwebz
    Home Page:
    Can anyone tell me what kind of code I can put in Greasemonkey to make this button get clicked on page load?

    Code:
    <div class="main_login_btn">
                                        <input class="gsbut" name="connect" value="Login" type="submit">
                                        
                                    </div>
    Let's assume I visit a site called somesite.com and sometimes I stay logged in and sometimes I'm logged out. For when I'm logged out I found a way to have the username and password fields get autofilled on page load. However I can't figure out how to get that "login" button clicked on page load, and that's what I need the script for.

    Can anyone whip something up real quick for me?

    Thanks
     
  2. Scorpion Ghost

    Scorpion Ghost Jr. VIP Jr. VIP

    Joined:
    Mar 22, 2013
    Messages:
    2,814
    Likes Received:
    1,094
    Occupation:
    Internet!
    Location:
    On the Interwebz
    Home Page:
  3. Max Blax

    Max Blax Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 21, 2017
    Messages:
    134
    Likes Received:
    44
    Gender:
    Male
    Occupation:
    Developer
    Location:
    Paradise
  4. Scorpion Ghost

    Scorpion Ghost Jr. VIP Jr. VIP

    Joined:
    Mar 22, 2013
    Messages:
    2,814
    Likes Received:
    1,094
    Occupation:
    Internet!
    Location:
    On the Interwebz
    Home Page:
  5. Max Blax

    Max Blax Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 21, 2017
    Messages:
    134
    Likes Received:
    44
    Gender:
    Male
    Occupation:
    Developer
    Location:
    Paradise
    I have tested this code on this website: https://www.playok.com/fr/dames10x10/

    Code:
    // ==UserScript==
    // @name     Dummy Test
    // @include  *://www.playok.com/fr/dames10x10/*
    // @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
    // @require  https://gist.github.com/raw/2625891/waitForKeyElements.js
    // @grant    GM_addStyle
    // ==/UserScript==
    
    waitForKeyElements ("#lbox", () => { document.querySelector('.lbpbg').click(); });
    
    and it works. Just to click on the connexion button after the page load (button class="lbpg")
     
    • Thanks Thanks x 1
  6. Scorpion Ghost

    Scorpion Ghost Jr. VIP Jr. VIP

    Joined:
    Mar 22, 2013
    Messages:
    2,814
    Likes Received:
    1,094
    Occupation:
    Internet!
    Location:
    On the Interwebz
    Home Page:
    Thanks man. I appreciate it :)