greasemonkey: addEventListener questions
I've a userscript as the following:
document.addEventListener('click', alert('hello monkey'), true);
There were two problems:
"hello monkey" is alerted only when refreshing the browser, not work when clicking window.
- 开发者_Go百科
using GM's 'manage user script' to edit the script, the change doesn't happen. (The source code on the local disc was changed.)
You need to bind it so it isn't executed automatically...
document.addEventListener('click', function(){alert('hello monkey')}, true);
Not sure about #2 though.
精彩评论