在 Google Chrome 重新加载网页,直到 HTML 包含特定文本

Reload Webpage in Google Chrome until HTML contains specific text

此代码适用于 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