Solution 1. Use Tampermonkey. Tampermonkey is more popular as an extension for Chrome, but it is also available as a standalone Android app. It functions as a lightweight browser, and allows you to manage and automatically run user scripts. Unfortunately it doesn't have many of the features found on other popular browsers, but it does support the Greasemonkey API.
Solution 2. Use Opera Mobile, which has built-in support for userscripts, but no script management features, and doesn't support the Greasemonkey API. Navigate to the User Prefs section of
.user.js extension. NB this works in OM12, but the OM14 beta doesn't seem to support userscripts at present.
This technique is tedious, but the principle should work in most browsers. You don't get Greasemonkey API support though. The code above should work without modification in the stock Android browser, and can be saved as a bookmarklet. In Chrome Mobile the space in the
var a needs escaping, i.e.
var%20a=, and bookmarklets don't seem to work, so you have to paste manually every time.