此代码适用于Safari(重载网页直到HTML包含特定文本)。如何修复它的Chrome?
tell application "Safari"
set keyword to "Authentication mail"
repeat
set myWindow to current tab of first window
activate
do JavaScript "window.location.reload()" in myWindow
repeat while (do JavaScript "document.readyState" in document 1) is not "complete"
delay 0.5
end repeat
set pageContent to do JavaScript ("window.document.documentElement.outerHTML") in myWindow
if pageContent contains keyword then
beep beep beep
exit repeat
end if
delay 2 -- wait a bit before running again
end repeat end tell
我不知道你的目标网站,所以我没有办法测试下面的代码。
tell application "Google Chrome"
set keyword to "Authentication mail"
repeat
set myWindow to active tab of first window
tell myWindow
activate
execute javascript "window.location.reload();"
repeat while (execute javascript "document.readyState;") is not "complete"
delay 0.5
end repeat
set pageContent to execute javascript "window.document.documentElement.outerHTML;"
if pageContent contains keyword then
tell current application to beep (beep (beep))
exit repeat
end if
delay 2 -- wait a bit before running again
end tell
end repeat
end tell