Created
May 31, 2013 16:04
-
-
Save kch/5686026 to your computer and use it in GitHub Desktop.
Enable private browsing mode, open a new page in Safari for the given URL.
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/env ruby | |
($stderr.puts(DATA.read.gsub("$0", File.basename($0))); exit 1) if ARGV.length != 1 | |
require 'appscript' | |
safari_app = Appscript.app("Safari") | |
safari_process = Appscript.app('System Events').processes['Safari'] | |
safari_app.activate | |
private_browsing_menu_item = safari_process | |
.menu_bars.first | |
.menu_bar_items['Safari'] | |
.menus['Safari'] | |
.menu_items['Private Browsing'] | |
private_browsing_enabled = !private_browsing_menu_item.attributes['AXMenuItemMarkChar'].value.get.nil? | |
private_browsing_menu_item.click unless private_browsing_enabled | |
safari_app.open_location(ARGV[0]) | |
__END__ | |
Enable private browsing mode, open a new page in Safari for the given URL. | |
Usage: | |
$0 <URL> | |
Example: | |
$0 http://heroku.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment