javascript - 在 Google Chrome 中重新加载网页,直到 HTML 包含特定文本
问题描述
此代码适用于 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
推荐阅读
- javascript - Javascript函数内部/外部/变量范围
- python - 带有情节的树状图 - 如何为层次聚类设置自定义链接方法
- python - 如何比较两行并通过Python中的索引获取结果?
- symfony - Symfony - 显示存储在公共之外的文件
- c++ - 尝试在 Windows 10 上运行 PARDISO 时出现未解决的外部符号错误
- json - 如何在 Para Web 控制台上编辑资源权限
- c++ - C++继承&虚函数问题
- php - 将 Cookie SameSite None 添加到 Drupal7 和 PHP7.0
- c - 将输入从 `getchar()` 复制到另一个变量
- angular - 错误:无法读取 null 的属性“userLocation”或服务为 null