Well I'm finally getting around to testing out this portion of GMC... and I'm not really sure how this was designed initially but in your GMC Unit Test the Magic button fails to alert "hey!"
Target init code:
...
'magic': {
'label': 'Magic Button',
'type': 'button',
'script': function() { alert('hey!'); }
},
...
I've narrowed it down to this line. Neither conditional appears to work. I did a simple test to see if it was GMs alert sandbox issue and it doesn't appear to be.
Since I haven't actually used this portion of GMC before I'm not sure if a recommended fix below will work, which scope is needed and how much backwards compatibility is needed.
At first glance it would appear that this code:
typeof scr == 'function' ? setTimeout(scr, 0) : eval(scr);
would seem to need to be:
typeof scr == 'function' ? scr() : eval(scr);
... but I don't know since I can't seem to find this input type in the documentation anywhere. Even looking at Joes branch code he has the same line as this one. Izzys docs don't appear to have a reference either.
Ideally I am not sure that GMC would want to support something other than an actual Function Object... e.g. don't allow the first string of code parameter for setTimeout
and most definitely do the best to avoid using eval
. e.g. that line should probably become:
if (typeof scr == 'function') scr();
What sort of future does this feature hold? It would nice to keep some sort of functionality in but it would appear that a change needs to be done for it to work. I can think of many ways to implement this.
Please advise. :)
Mozilla/5.0 (X11; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0
Greasemonkey 1.8.x
Well-used running profile