[Greasemonkey] modifying maxlength

Lenny Domnitser ldrhcp at gmail.com
Mon Oct 10 12:59:41 EDT 2005


On 10/10/05, mp3geek <mp3geek at gmail.com> wrote:
> Thanks to Mook for this code, however the webpage still shows a
> maxlength=20 rather, any help would be greatly appreciated :)

In the HTML:
<input name='user_name' value="this-is-a-long-test.long-test-i-say"
type='text' maxlength='20' size='30' class=text>

Greasemonkey modifies the page after it has already loaded, so this
script does increase maxlength to 50, but after it has already
truncated the starting value.

You say it "shows maxlength=20". I'm not sure if you mean by behavior
or in the source. As far as behavior goes, I can type up to 50
characters with the script install. If you are looking at the source
code, realize that View Source only shows what was sent over the wire
originally. To see what you have after the quirks mode fixer and
Javascripts have their way, look at
document.documentElement.innerHTML, or the DOM inspector.

If you really have to modify a page before it reaches the browser so
that you can have a higher maxlength before page load, try MouseHole
[1]. (Disclaimer: I, not knowing Ruby and not needing to modify pages
before load, have not used MouseHole.)

[1]: http://mousehole.rubyforge.org/


More information about the Greasemonkey mailing list