为什么这不起作用? JavaScript
这是一个油脂猴脚本。我不懂 javascript,所以这使得这特别有趣。
function notify(){
if window.find("1 minute")==true{
alert("y");
setTimeout("alert('time to click soon!')",60000)
}
if window.find("2 minute")==true{
alert("y");
setTimeout("alert('time to click soon!')",2*60000)
}
...重复x30...
}
notify();
提前致谢。
It's a greasemonkey script. I don't know javascript so that makes this especially fun.
function notify(){
if window.find("1 minute")==true{
alert("y");
setTimeout("alert('time to click soon!')",60000)
}
if window.find("2 minute")==true{
alert("y");
setTimeout("alert('time to click soon!')",2*60000)
}
...repeated x30...
}
notify();
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您缺少
if
条件两边的括号。它们应该看起来像:另外,不需要显式测试
true
;if
语句可以为您做到这一点!更多可以让 Douglas Crockford 减少对你生气的事情
不要将字符串传递到
setTimeout
中。传递函数。像这样:或者像这样(更好,因为您正在重用该函数):
You're missing parentheses around the
if
conditionals. They should look like:Also, no need to explicitly test against
true
; theif
statement does that for you!More things to make Douglas Crockford less angry with you
Don't pass strings into
setTimeout
. Pass functions. Like this:or like this (even better, since you're reusing the function):
另外,我认为您可能应该使用 unsafeWindow。
Also, I think you should probably be using unsafeWindow.