Monday, November 26, 2018

auto fill login form with greasemonkey

1- install firefox plugin using url below
https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/


2- script example
// ==UserScript==
// @name     Mysite-login Script 353401
// @version  1
// @grant    none
// ==/UserScript==

var numIntervals    = 0;   
var pwFilledTimer   = setInterval ( function () {
        var usrNameInp  = document.getElementById ("username");
              usrNameInp.value = "userx1";
        if (usrNameInp  &&  usrNameInp.value != "") {

            var passWrdInp  = document.getElementById ("password");
            passWrdInp.value = "passwordx1";
            if (passWrdInp  &&  passWrdInp.value != "") {

                clearInterval (pwFilledTimer);

                var submitButton = document.querySelector (
                    'input[type="submit"][value="Login"]'
                );
                var clickEvent  = document.createEvent ('MouseEvents');
                clickEvent.initEvent ('click', true, true);
                submitButton.dispatchEvent (clickEvent);
            }
        }
        numIntervals++;
        if (numIntervals > 10) {
            /*--- Stop the timer after about 2 seconds so it doesn't
                interfere with manual logins.
            */
            clearInterval (pwFilledTimer);
        }
    },
    200
);



3-  go to "User script options" and type url that you want the script to execute in "user include" box example:
http://www.google.com/*


later when you visit www.google.com, the script will execued.

No comments:

Post a Comment