Posted under » JavaScript on 5 December 2010
One of the easiest method to practice Javascript is to write a tampermonkey or greasemonkey script.
A simple autologin script for tampermonkey
// ==UserScript== // @name temperature update // @namespace loop // @version 0.1 // @description tired of login // @author Hanafi Harron // @match https://lms.loop.sg/users/users/login // @grant none // ==/UserScript== (function() { 'use strict'; var name = "hanafiharron" var pass = "LOOP@ACP1a" document.getElementById('input_email').value = name document.getElementById('input_password').value = pass })();Or if Greasemonkey
// ==UserScript== // @name auto login // @namespace anoneh // @description auto login script // @include http://www.drupalsite.com/ // ==/UserScript== var name = "admin" var pass = "bassword" document.getElementById('edit-name').value = name document.getElementById('edit-pass').value = pass
However, not all forms has id but have name only. In this case.
var zTextFields = document.getElementsByTagName("input"); for (var i=0; i < zTextFields.length; i++) { var thefield; thefield=zTextFields[i].name; if (!thefield) thefield=zTextFields[i].id; // Set up your auto-fill values here if (thefield == "username") zTextFields[i].value="bradpitt"; if (thefield == "password") zTextFields[i].value="jolie"; // alert("field:" + thefield + " value: " + zTextFields[i].value); }