Code
// ==UserScript==
// @name AutoLogin
// @namespace http://www.squarefree.com/userscripts
// @description Automatically submits login forms where Firefox has remembered the password.
// @include -------- hier steht die interne Adresse, wo das script aktiv werden soll -------------------------
// ==/UserScript==
/*
Author: Jesse Ruderman - http://www.squarefree.com/
Version: 1.3
1.0 - first version
1.1 - fix some JS strict warnings
1.2 - bonk the first submit button, not the last submit button (fixes e.g. delicious)
1.3 - skip if password field's value is "Password" (fixes e.g. ddrfreak)
Competing scripts and extensions:
* http://labs.beffa.org/greasemonkey/AutoLogin.user.js
* http://www.extensionsmirror.nl/index.php?showtopic=962
*/
function submitFirstPasswordForm()
{
for (var form, i=0; form=document.forms[i]; ++i) {
var numPasswordElements = 0;
var submitButton = null;
var formElement, j;
for (j=0; formElement=form[j]; ++j)
if (formElement.type == "password" && formElement.value && formElement.value.toLowerCase() != "password")
++numPasswordElements;
if (numPasswordElements == 1) { // probably a login form (and not a change-password form or something like that)
/*
* The obvious way to submit a login form is form.submit(). However, this doesn't
* work with some forms, such as the Google AdWords login. Instead, find a
* submit button and bonk it.
*/
// look for a submit button
for (j=0; formElement=form[j]; ++j)
if (formElement.type == "submit") {
submitButton = formElement;
break;
}
// also look for (and prefer) <input type=image>
// why this extra loop? <input type=image> isn't form[j] for any j
// (see bug 113197 or http://whatwg.org/specs/web-forms/current-work/#additions)
for (j=0; formElement=form.getElementsByTagName("input")[j]; ++j)
if (formElement.type == "image") {
submitButton = formElement;
break;
}
if (submitButton) {
// Give a visual indication that we're submitting the login form automatically.
submitButton.focus();
submitButton.style.MozOutline = "2px solid purple";
// Submit the form by calling click() on the submit button.
submitButton.click();
// Break out of both loops.
return;
}
}
}
}
window.addEventListener(
"load",
function() {
// Use a setTimeout so Firefox's password manager has a chance to fill in the password.
setTimeout(submitFirstPasswordForm, 0);
},
false
);
Alles anzeigen
Danke!
Ich sollte noch erwähnen, dass das Script auf anderen PCs problemlos läuft. Erst wenn etwas neu installiert wird (z. B. die ESR-Version testweise) kommen diese Probleme mit Greasemonkey.