[Greasemonkey] Too many IDs?

Brendan Crosser-McGay verifex at gmail.com
Tue Sep 27 17:06:50 EDT 2005

I have found a curious problem, maybe this is something to do with mozilla
and memory usage?

I've got Firefox 1.0.7 running with Tabbrowser prefs<>,
Download Manager Tweak 0.6.6, Livebookmark This 0.2, Mouse Gestures
1.0.2and finally Greasemonkey
0.5.3 running.

I am using a script that assigns ID tags to a bunch of span tags it injects
into a page (sometimes up to 200 per page). Randomly, the entire script
fails, as though nothing happened. Sometimes it will succeed, then fail, and
sometimes it will work just fine. I wanted to know, is there another way to
address massive specific amounts of elements with psuedo JS added into the
page (JS added to function on the page, using GM to insert that extra JS
code. I'm frustrated because I can run a set of code, I add this extra
variable to the code, run it and it doesn't work. However if I remove that
code, at that point, it still crashes.

Here is a snippt of code that seems to work for a while:
toggleswitch="<select onChange='for(i=0;i<tb.length;i++) {";
toggleswitch=toggleswitch+"if ((document.getElementsByTagName
toggleswitch=toggleswitch+" if ((document.getElementsByTagName
toggleswitch=toggleswitch+"}'><option value=1>Collapse All</option><option
value=2>Expand All</option></select>";

But as soon as I add this code in the place of the line above, it breaks and
stays broken, even after I remove this code:
toggleswitch=toggleswitch+" if (this.options[this.selectedIndex].value==3)
toggleswitch=toggleswitch+" if
toggleswitch=toggleswitch+" if (ns.innerHTML.match(/[0-9]+
[0-9][0-9][0-9][0-9]/)) {";
toggleswitch=toggleswitch+" document.getElementsByTagName
toggleswitch=toggleswitch+" }";
toggleswitch=toggleswitch+" }";
toggleswitch=toggleswitch+" }";

More information about the Greasemonkey mailing list