Saturday, July 11, 2020

#1 2013-12-15 10:51:45 am

Registered: 2009-02-07
Posts: 413 - Open List-Serve Page in Safari

Hey Folks,

On a fairly regular basis I want to visit the list-serve page related to a list-mail-message I've received.

I hate having to fiddle around to get there, so I wrote a script and have bound it to Cmd-Opt-Ctrl-A with FastScripts.

My previous script was pretty hard-coded, but since Apple fixed headers in Mavericks Mail I rewrote it to be a bit more flexible.

It works with Yahoo Groups, Google Groups, and assorted other lists that have a list-archive header.


# Auth: Christopher Stone
# dCre: 2013-04-02 : 14:00
# dMod: 2013-12-15 : 10:04
# Appl: Apple Mail & Default browser
# Task: Visit List-Serve Page Related to List-Mail-Message if Available.
# Libs: None
# Osax: None
# Tags: @Applescript, @Mail, @List, @Archive, @Header, @Browser

   set listArchiveUrl to {}
   set yahooGroupsBaseURL to "[url][/url]"
   tell application "Mail"
       set _msg to selection
       if length of _msg = 1 then
           set _msg to item 1 of _msg
           error "No messages OR too many messages are seleced!"
       end if
       tell _msg
           set listID to content of (headers whose name is "List-Id")
           if listID ≠ {} then
               set listID to item 1 of listID
           end if
           set listArchiveUrl to content of (headers whose name is "List-Archive")
           if listArchiveUrl ≠ {} then
               set listArchiveUrl to item 1 of listArchiveUrl
           end if
           if listArchiveUrl = {} then
               if listID contains "" then
                   set listArchiveUrl to "[url][/url]"
               else if listID contains "" then
                   set _cmd to "<<< " & (quoted form of listID) & " sed -E '

                   set listID to do shell script _cmd
                   set listArchiveUrl to yahooGroupsBaseURL & listID & "/"
               end if
           end if
       end tell
   end tell
   if listArchiveUrl is in {{}, ""} then
       set _cmd to "<<< " & (quoted form of listArchiveUrl) & " sed -E 's!^<|>$!!g'"
       set listArchiveUrl to do shell script _cmd
       tell application "Safari"
           make new document with properties {URL:listArchiveUrl}
           set bounds of front window to {228, 22, 1542, 1196}
       end tell
   end if
on error e number n
   stdErr(e, n, true, true) of me
end try


on stdErr(e, n, beepFlag, ddFlag)
   set e to e & return & return & "Num: " & n
   if beepFlag = true then
   end if
   if ddFlag = true then
       tell me
           set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
       end tell
       if button returned of dDlg = "Copy" then set the clipboard to e
       return e
   end if
end stdErr




Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)