使用AppleScript重新加载特定页面的所有镶边选项卡

时间:2019-03-27 00:32:46

标签: applescript

我正在尝试重新加载某个页面的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.

我该怎么做?

2 个答案:

答案 0 :(得分:0)

这适用于我使用最新版本的macOS Mojave和Chrome的情况。

tell application "Google Chrome" to set allTabs to a reference to (tabs of windows whose URL contains "mypage.com") 
tell application "Google Chrome" to reload allTabs

答案 1 :(得分:0)

如果打开了至少包含一个带有mypage.com标签的 Chrome 窗口,则@ wch1zpink提交的答案将不起作用网址。不幸的是,您需要遍历窗口:

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