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 // @include http://www.drupalsite.com/ // ==/UserScript== (function() { 'use strict'; var name = "admin" var pass = "bassword" document.getElementById('edit-name').value = name document.getElementById('edit-pass').value = pass })();You will notice the use strict thingie. It is there for a reason. Use it and don't get put off by it.
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); }