开发者

greasemonkey: addEventListener questions

开发者 https://www.devze.com 2023-01-07 18:40 出处:网络
I\'ve a userscript as the following: document.addEventListener(\'click\', alert(\'hello monkey\'), true);

I've a userscript as the following:

document.addEventListener('click', alert('hello monkey'), true);

There were two problems:

  1. "hello monkey" is alerted only when refreshing the browser, not work when clicking window.

  2. 开发者_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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号