Previous APOD Page
Previous APOD Page
- Subject: Previous APOD Page
- From: Christopher Stone <email@hidden>
- Date: Mon, 27 Aug 2012 20:06:57 -0500
Hey Folks,
Like many people I enjoy the APOD, and also like many people I often forget to visit it daily.
Enter Applescript.
This script will jump backwards one day from the currently viewed APOD page, so you can quickly review what you missed.
I run mine via a keyboard shortcut with FastScripts.
--
Best Regards,
Chris
------------------------------------------------------------------------------------------------
# Safari
# Go to previous APOD page
# APOD: http://apod.nasa.gov/apod/
------------------------------------------------------------------------------------------------
try
tell application "Safari"
tell front document
set pageURL to quoted form of (get URL)
set urlPath to do shell script "sed -E 's|[^/]+$||' <<< " & pageURL
set src to quoted form of (do shell script "tr '\\r' '\\n' <<< " & (quoted form of (get source)) without altering line endings)
set previousApodURL to urlPath & (do shell script "echo " & src & " | sed -n '/></p' | sed -E 's/[^\"]+\"([^\"]+).+/\\1/'")
set URL to previousApodURL
end tell
end tell
on error eMsg number eNum
set {c, s} to {return, "------------------------------------------"}
set e to s & c & "Error: " & eMsg & c & s & c & "Error Number: " & eNum & c & s
beep
set dDlg to display dialog e buttons {"Cancel", "Copy", "OK"} default button "OK"
if button returned of dDlg = "Copy" then
set the clipboard to e
end if
end try
------------------------------------------------------------------------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden