[Greasemonkey] Inspecting / Modifying global in-page variables in 0.6

Jeremy Dunck jdunck at gmail.com
Thu Sep 15 10:07:51 EDT 2005

On 9/15/05, Anthony Lieuallen <arantius at gmail.com> wrote:
> On 9/14/05, Aaron Boodman <zboogs at gmail.com> wrote:
> > Wow, there really should be no difference at all. Could it be that you
> > arent declaring the 'val' variable?
> No, adding the line "var val;" to the top of the user script does not
> help.  Adding "dump(key+'\n');" directly inside the for loop shows the
> "myval" key is never iterated.


>From the wiki page:

You cannot iterate over HTMLCollections with an "in" statement. Consider 

var arInputs = document.getElementsByTagName('input'); 
for (var elmInput in arInputs) { ... } 

This no longer works in Deer Park, because arInputs is an
XPCNativeWrapper of an HTMLCollection, and you can't iterate through
an XPCNativeWrapper with an "in" statement. Instead, you need to do
var arInputs = document.getElementsByTagName('input'); 
var elmInput; for (var i = 0; elmInput = arInputs[i]; i++) { ... } 

I realize unsafeWindow isn't an HTMLCollection, but perhaps the
problem is wider than that...

More information about the Greasemonkey mailing list