javascript - Applescript : wait that the page is load on chrome

标签 javascript google-chrome applescript document-ready

tell application "Safari"
        repeat until (do JavaScript "document.readyState" in tab 2 of window 1) is "complete"
        end repeat
    end tell
end if

如何在 Chrome 中使用此功能?

最佳答案

你应该能够做到

tell application "Google Chrome"
repeat until (execute tab 1 of window 1 javascript "document.readyState" is "complete")
end repeat
    execute tab 1 of window 1 javascript "document.readyState"
end tell

但您的页面可能会永远或在很长一段时间内返回“交互”状态。

仅使用 AppleScript 执行此操作应该是:

tell application "Google Chrome"
    repeat until (loading of tab 1 of window 1 is false)
        1 + 1 --just an arbitary line
    end repeat
    loading of tab 1 of window 1 --this just returns final status
end tell

但是,说实话,我觉得这很可疑。我有一个页面的正文中只有非常简单的 html ( http://www.crgreen.com/boethos/boethos.html ),并且它可以使用它,但对于大多数页面(我已经尝试过 yahoo、macupdate、bbc news、jedit.org 等)我不是永远得到“loading = true”。可能有问题。

关于javascript - Applescript : wait that the page is load on chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42292181/

相关文章:

html - 覆盖页面的动态列表......但仅限于 Chrome for Android

css - 无法覆盖 CSS 填充

macos - 隐藏菜单栏并与applescript全局停靠

Applescript 从 iTunes URL 播放音乐

c# - 从 C# 到 javascript 的字符串数组示例不起作用

javascript - Dimple.js 条形图转换包括删除的条形图

google-chrome - 如何关闭chrome浏览器自动更新

javascript 属性值依赖于其他属性

javascript - 此请求返回的 header 状态

macos - 列出所有应用程序 - 输出为文本文件