How can I run a function upon the first run of a greasemonkey script?
+2
A:
You can use GM_setValue
and GM_getValue
to store setting etc.
Try "getting" a flag. If it isn't set, make your first run call and then set the value. eg
var isfirstrun = GM_getValue('firstrun', '0');
if (isfirstrun == '0')
{
// value not set, so must be the first run
DoSomething();
GM_setValue('firstrun', '1');
}
The docs are here
rikh
2009-11-11 11:15:16