首页 > 解决方案 > 使用 AppleScript 重新加载某个页面的所有 chrome 选项卡

问题描述

我正在尝试重新加载某个页面的所有 Chrome 选项卡(我可以打开许多窗口)。这就是我所做的:

tell application "Google Chrome"
    set {ids} to every window
    repeat with id in ids
        reload (tabs of window id whose URL contains "mypage.com")
    end repeat
end tell

但我明白了Google Chrome got an error: Can’t make item 1 of window id 1 into type integer.

我该怎么做呢?

标签: applescript

解决方案


如果打开的任何Chrome窗口包含至少一个带有mypage.comURL的选项卡, @wch1zpink 提交的答案将不起作用。不幸的是,您需要遍历窗口:

tell application "Google Chrome" to repeat with W in windows
    reload (every tab in W whose URL contains "mypage.com")
end repeat

推荐阅读