11

I have a mac mini setup on a tv to monitor our network. I'd like to setup the monitoring pages we'd like to view in a set of tabs and have safari automatically cycle through them. Something like how gas stations use to change video feeds; some sort of auto-switcher.

I looked at glims but it doesn't appear to have the functionality. Is there a way to do this with base safari or does anyone know of a plugin that will do this behavior in Safari?

3
  • Does it have to be Safari? There's a plugin for Chrome which does this.
    – Vlad
    Feb 6, 2012 at 14:29
  • I am aware that Chrome and Firefox both have extensions that will handle this, but I was curious if Safari had the ability natively. Feb 6, 2012 at 16:16
  • You can certainly do it in Applescript The object hierarchy is very simple - Application - Windows (Window) - Tabs (Tab)
    – Stu Wilson
    Feb 6, 2012 at 21:26

2 Answers 2

19

You can use this block of AppleScript to loop through your tabs on a window:

tell application "Safari"
    repeat
        repeat with i from (count of tabs of window 1) to 1 by -1
            set thisTab to tab i of window 1
            set current tab of window 1 to thisTab
            delay 1
        end repeat
    end repeat
end tell

This will go through all your tabs and switch every 1 second. Just change the delay to change the time before each tab switches.

2
  • Use built-in AppleScript Editor to write, save and run it. Works beautifully, thanx!
    – JOM
    Apr 1, 2016 at 9:19
  • Confirmed still working perfectly on macOS 10.15.7. The built-in app name to write and run it with is "Script Editor".
    – Marc L
    Nov 30, 2020 at 19:04
0

I found myself wanting to update the tabs on many windows at once by cycling to the next tab, and then back to the beginning.

In my case the windows are identified by having title prefix in common, and my delay is 20s

tell application "Safari"
repeat
    set theWindows to windows
    set windowCount to count of theWindows
    -- log windowCount as text
    repeat with theWindow in theWindows
        set windowName to name of theWindow
        if windowName starts with "<common_prefix>" then
            set tabCount to count of the tabs of theWindow
            set currentTabIdx to index of current tab of theWindow
            log currentTabIdx
            if currentTabIdx = tabCount then
                set currentTabIdx to 0
            end if
            set current tab of theWindow to tab (currentTabIdx + 1) of theWindow
        end if
        end repeat
        delay 20
    end repeat
end tell

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .