Greasemonkey script to click a button


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

Bump…

I tried multiple things before I posted here, and I couldn’t get it to work.

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 :)

@Max Blax

This worked. Thanks :)

Related Post

Check Our Service

Do You need SEO SERVICE?

If you’re looking for a professional who can help you increase your search engine traffic, we’ve got just the thing. SEO isn’t hard; all you have to do is tell me what you need help with below.