[Greasemonkey] bug 11423
Lenny Domnitser
ldrhcp at gmail.com
Tue Aug 30 17:21:42 EDT 2005
> To compensate for the slowness, I will concatenate all the user scripts for a
> given page together into one mega script to execute all at once. This means that
> malicious user scripts could interfere with one another on 1.0.x, but I feel
> that this is acceptable.
Scripts will interfere with each other if simple concatenation is
used, but not if the setTimeout hack is used, like so:
// Let's assume the variable "scripts" is an array of script strings,
// and the variable "chunkToExecute" is a string.
// Obvioulsy this can be adapted to the real var names.
for(var c = 0; c < scripts.length; c++) {
// do not do this: chunckToExecute += scripts[c] + '\n';
// this is good:
chunckToExecute += 'setTimeout(function(){' + scripts[c] + '\n},0);';
}
Don't forget the \n, in case a script ends in a comment.
More information about the Greasemonkey
mailing list