Reload all Safari Tabs?

Anyone got a macro or AppleScript or something that reloads all tabs in Safari?

Reloads them from where?

Try a search on:
tags:safari tabs

Cmd+R, or View->Reload This Page. For all tabs.

I think you know the answer to this:

Step through each tab, and issue either the shortcut or the KM menu item.

Did you read my first post? What did I ask? Hmmm? Did I ask how to do it? No I did not! I’m frickin’ lazy!! :slight_smile:

Actually, I just wanted to make sure someone else didn’t have the code handy before I wrote it.

I'm pretty sure that if you do the search I suggested, you will find a script and/or macro that cycles through all tabs in Safari. Adding the KM menu item is then trivial.

I asked:

Anyone got a macro or AppleScript or something that reloads all tabs in Safari?

That's what I want to know. A simple question. You know I know how to do what you suggested. I was just asking a simple question. I didnt even ask anyone to write it for me. I just wanted to check for existing code first.

I don't think this is a difficult concept, is it?

Nope. Sorry, didn't mean to offend you.
I know I've asked the same thing.

I just thought that you could get an answer more quickly by the Search than waiting for someone to respond. But maybe I'm wrong.

I'd bet that Chris (@ccstone) has a script for this in his back pocket, but I haven't seen him around a much lately.

1 Like

You've done so much for me, I just wrote this for you.
It has had only very very limited testing, but it should get you going.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "Safari"
  set winList to every window whose name ≠ ""
  
  repeat with oWin in winList
    
    set tabList to every tab in oWin
    
    
    repeat with oTab in tabList
      set tabURL to URL of oTab
      set URL of oTab to tabURL
    end repeat
    
  end repeat
  
end tell

For ref, see:
AppleScript: How to reload a Safari window

1 Like

Hey Dan,

Yep.  :sunglasses:

-Chris

--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2011/08/09 20:33
# dMod: 2015/11/14 16:46
# Appl: Safari
# Task: Reload Every Tab in front window.
# Libs: None
# Osax: None
# Tags: @Applescript, @Safari, @Reload, @Tabs, @Front, @Window
--------------------------------------------------------------------------------

tell application "Safari"
   
   set tabList to tabs of front window
   
   repeat with ndx1 in tabList
      tell ndx1 to do JavaScript "location.reload(true)"
   end repeat
   
end tell

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2011/08/09 20:33
# dMod: 2011/08/09 20:57
# Appl: Safari
# Task: Reload Every Tab in Every Window.
# Libs: None
# Osax: None
# Tags: @Applescript, @Reload, @Tabs, @Every, @Window
--------------------------------------------------------------------------------

tell application "Safari"
   
   set tabList to tabs of (windows where its document is not missing value)
   
   repeat with ndx1 in tabList
      repeat with ndx2 in ndx1
         tell (ndx2's contents)
            do JavaScript "location.reload(true)"
         end tell
      end repeat
   end repeat
   
end tell

--------------------------------------------------------------------------------
2 Likes

Ahem, um, yeah, sorry about that. Don't know why I got my feathers ruffled. In retrospect, I was kind of a jerk.

So, sorry. I can't say I won't do it again, but I'll try not to. :blush:

1 Like