Universal Sign-In Button


This page will create a custom bookmarklet for you, just provide your url and save the link to your bookmarks. You will then be able to run the bookmarklet on any page that requests your web address to sign in.

What does this do?


There are only a few lines of code in this bookmarklet, so it's quite easy to understand. The formatted code is displayed below, feel free to use and modify it as required.

The first step is to find all the forms on the current page. Then we want to narrow this list down to just those that have one input field, and mention something in their text about Sign In, Log In, or Web Address.

Once we have the single input field that matches this description, we set to it's value to the custom url. Next we look for buttons in the form we can click to submit it, and just click all the things.

Note that calling form.submit() would be easier, but that skips any javascript events that may be bound to the form. That means clicking is a nicer way to allow the page to perform it's own action.
 

(function() {
  document.querySelectorAll('form').forEach(function(form) {
    var input = form.querySelectorAll('input:not([type=button]):not([type=submit]):not([type=hidden])');
    if (input.length === 1 && /login|log.in|sign.in|address/.test(form.innerHTML.toLowerCase())) {
      input[0].value = 'custom url goes here';
      form.querySelectorAll('input[type=button],input[type=submit],button').forEach(function(button){
        button.click();
      });
    }
  });
}());