I’m writing a script to add extra smileys to the Gmail chat.
Its working partially, i’m stuck with the innerHTML.replace method @line 33
If you see, the regex in the replace method is passed using a variable. This is where the script is choking.
If i replace the variable with the actual regex, it works fine 😐
Each timeout closure ends up with the latest value for the two variables, not the value for the current iteration. In the code, there’s only one iteration, but I assume that’s just simplified for posting. You can change it to something like:
This way, each iteration step has its own set of variables. However, I’m not sure whether you actually need the timeout.