I can’t find keyboard access to the little blue RSS toggle button in Safari 2, I even snooped around menubar nib looking for a connection, but couldn’t find it. I think it should be a simple matter for AS to do a JS in Safari to get this info from the link rel tag, but I’m unsatisfied with the methods that come to mind. Can anyone steer me in a better direction?
Edit: here’s code based on the link I made to my old post. It seems to work ok, I guess I was just hoping for a more direct way of finding specific tags with JS that’s a step up from repeat loops.
tell application "Safari"
set rss_link to ""
repeat with x from 0 to 5 by 1
do JavaScript "document.getElementsByTagName(\"link\").item(" & x & ").type" in front document
if result is "application/atom+xml" or result is "application/rss+xml" then
set rss_link to (do JavaScript "document.getElementsByTagName(\"link\").item(" & x & ").href" in front document)
if rss_link does not contain "://" then
set _path to (URL of front document)
tell (a reference to AppleScript's text item delimiters)
set {tid, contents} to {contents, "/"}
set {_path, contents} to {(text items 1 thru -2 of _path as text) & "/", tid}
end tell
set rss_link to _path & rss_link
end if
set URL of front document to rss_link
exit repeat
end if
if x is 5 then beep
end repeat
end tell
All suggestions and magical alternatives eagerly welcomed.
try
tell application "System Events" to ¬
tell process "Safari" to ¬
click button 1 of text field 1 of splitter group 1 of group 4 of tool bar 1 of window 1
end try
Otherwise, you may find a better way to handle “link” tags (eg, MacScripter’s front page is “application/rss+xml”).
Thank you for the reply jj. I think the group index changes from machine to machine, but in my case I neglected to mention that I always keep my address bar hidden, and use instead the automatic show/hide behavior of cmd-L for getting around the web.
Good point. Repeat loops are looking better by the minute.