Introduction
User JavaScript is a technology offered by the Opera webbrowser to change webpages on the fly, either to fix problems or enhance the user experience. Firefox has an equivalent technology, called Greasemonkey.
Fixing Wand on MijnPostbank.nl
Changes in the code of de Dutch banking site, MijnPostbank.nl, stopped Wand (or any password manager for that matter) from working. Every time the page loads, a unique ID is added to the input fields on their login page (possibly added from an anti-phishing point of view), and as password managers rely on such a value to remember the login data, they stopped working. This can be fixed using UserJS, but only after UserJS on https is enabled.
JavaScript
The script works rather simple: when loading the page, retrieve the unique id values on the input fields, store them and replace them by a value that can be remembered by Wand across sessions. Then when submitting the form, restore the original id values, and login works as expected.
// ==UserScript==
// @name Fix Wand on MijnPostbank.nl
// @author Mark Schenk
// @namespace http://www.markschenk.com
// @version 1.0
// @description Allows Wand to work on MijnPostbank.nl by changing the random id values on the input fields.
// @include https://mijn.postbank.nl/internetbankieren/*
// ==/UserScript==
if(location.href.match(/^https:\/\/mijn\.postbank\.nl\/internetbankieren\/SesamLoginServlet/) ) {
document.addEventListener('load',maakWandMogelijk,false);
}
function maakWandMogelijk() {
var inlogformulier = document.getElementsByTagName('form')[0];
if(inlogformulier) {
inlogformulier.setAttribute('onsubmit','corrigeerVoorSubmit()');
// zoek inlognaam/wachtwoord velden
var inputs = inlogformulier.getElementsByTagName('input');
for(var i=0; i<inputs.length; i++) {
if(inputs[i].type == 'text' || inputs[i].type == 'password') {
inputs[i].setAttribute('storage',inputs[i].id);
inputs[i].id = 'mpb_' + inputs[i].type;
inputs[i].name = 'mpb_' + inputs[i].type;
}
}
opera.postError('Wand Fix Applied to MijnPostbank.nl')
}
}
function corrigeerVoorSubmit() {
// zet de originele waarden terug
var wachtwoordveld = document.getElementById('mpb_password');
wachtwoordveld.name = wachtwoordveld.getAttribute('storage');
wachtwoordveld.id = wachtwoordveld.getAttribute('storage');
var inlogveld = document.getElementById('mpb_text');
inlogveld.name = inlogveld.getAttribute('storage');
inlogveld.id = inlogveld.getAttribute('storage');
// originele MijnPostbank functie
return klik();
}