Last active
August 29, 2015 14:20
-
-
Save johan/399c9fa1f9f5426ce248 to your computer and use it in GitHub Desktop.
Osascript shell hack to engage "Reader View" after loading a url in Safari
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/osascript | |
# opens url $1 in Safari and tries to engage its Reader View (if it shows up within 15s) | |
# You will probably need to first add Terminal.app here (osx Yosemite; 10.10.3): | |
# System Preferences -> Security & Privacy -> Privacy -> Accessibility | |
on run argv | |
set article_url to item 1 of argv | |
tell application "Safari" to open location article_url | |
# uncomment to makes the Safari window 800px wide, snapped to the right of a macbook pro retina display | |
# tell application "Safari" to set bounds of front window to {640, 0, 1440, 878} | |
activate application "Safari" | |
tell application "System Events" to tell process "Safari" | |
repeat 15 times | |
set url_bar to text field "Address and Search" of group 2 of toolbar 1 of front window | |
if exists button "Show Reader" of url_bar then exit repeat | |
delay 1 | |
end repeat | |
if exists button "Show Reader" of url_bar then | |
click button "Show Reader" of url_bar | |
end if | |
end tell | |
return | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment