[Greasemonkey] Patterns

Edward Lee edilee at gmail.com
Mon Apr 18 13:58:36 EDT 2005

On 4/18/05, Mark Pilgrim <pilgrim at gmail.com> wrote:
> I agree that this is cool but I can't see the use, because I am a Bear
> Of Little Brain, and an "S" in the Myers-Briggs personality test, and
> I generally can't understand anything without a working example.  Have
> you written a user script that required this trick?

I use it a lot in http://ed.agadak.net/greasemonkey/ffCounter/ffCounter.php

Generally I used it in a loop.. you can copy/paste this into
javascript shell and look back on the original page.

for (var i = 0; i < 1000; i++) {
  setTimeout((function(i) { return function() {
    // do something with the current value of i
    // because without this trick, you'll get only the last value of i (10)
    // most likely it's for some delayed effect because it's setTimeout
    document.body.innerHTML = i;
  }; }) (i), i * 100);


More information about the Greasemonkey mailing list