Greasemonkey script to click a button

Scorpion Ghost

Elite Member
Executive VIP
Jr. VIP
Joined
Mar 22, 2013
Messages
9,144
Reaction score
10,489
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
 
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")
 
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 man. I appreciate it :)
 
Back
Top