Created
December 9, 2009 09:05
-
-
Save matthewtodd/252356 to your computer and use it in GitHub Desktop.
Command-line Google Voice dialer and Mac OSX Address Book Plug-In
This file contains hidden or 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
-- Drop this script in ~/Library/Address Book Plug-Ins | |
-- Edit the path in the "do shell script" line | |
using terms from application "Address Book" | |
on action property | |
return "phone" | |
end action property | |
on action title for aPerson with aNumber | |
return "Dial with Google Voice" | |
end action title | |
on should enable action for aPerson with aNumber | |
return true | |
end should enable action | |
on perform action for aPerson with aNumber | |
set aNumber to (value of aNumber as string) | |
do shell script "/Users/mtodd/Code/gvd/bin/gvd " & aNumber | |
return true | |
end perform action | |
end using terms from | |
property ASDScriptUniqueIdentifier : "MatthewGoogleVoiceDialerAction.applescript" |
This file contains hidden or 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
#!/opt/local/bin/ruby -wKU | |
require 'rubygems' | |
require 'mechanize' | |
require 'logger' | |
require 'yaml' | |
module WWW | |
class Mechanize | |
def submit_form(fields={}) | |
form = current_page.forms.first | |
form.set_fields(fields) | |
yield form if block_given? | |
form.click_button | |
end | |
end | |
end | |
configuration = YAML.load(DATA) | |
number_to_dial = ARGV.shift || configuration['dial']['to'] | |
WWW::Mechanize.new do |agent| | |
agent.user_agent_alias = 'iPhone' | |
agent.follow_meta_refresh = true | |
agent.log = Logger.new(STDOUT) | |
agent.log.level = Logger::INFO | |
agent.log.formatter = lambda { |severity, time, progname, msg| "#{msg}\n" if msg =~ /Net::HTTP/ } | |
agent.get('https://www.google.com/voice/m') | |
agent.submit_form(configuration['credentials']) | |
agent.submit_form('number' => number_to_dial) | |
agent.submit_form { |form| form.radiobutton_with(:value => configuration['dial']['from']).check } | |
end | |
__END__ | |
credentials: | |
Email: ELIDED | |
Passwd: ELIDED | |
dial: | |
from: ELIDED | |
to: ELIDED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment