Skip to content

Instantly share code, notes, and snippets.

@mpasternacki
Created April 28, 2012 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpasternacki/2522659 to your computer and use it in GitHub Desktop.
Save mpasternacki/2522659 to your computer and use it in GitHub Desktop.
AppleScript to consistently log into multiple Google Apps account in Safari
on js(jscpt)
set jscpt to "(function _l () {" & jscpt & "}());"
tell application "Safari" to do JavaScript jscpt in document 1
end js
on log_into_google(method, username, password)
tell application "Safari" to set URL of document 1 to "https://accounts.google.com/" & method
delay 2
js("var f = document.getElementById('gaia_loginform');
f.Email.value = '" & username & "';
f.Passwd.value = '" & password & "';
f.submit();")
delay 7
end log_into_google
activate application "Safari"
tell application "Safari"
make new document at end of documents
set URL of document 1 to "https://accounts.google.com/logout"
end tell
delay 10
log_into_google("ServiceLogin", "primary_account", "password1")
log_into_google("AddSession", "other_account", "password2")
log_into_google("AddSession", "account@domain1.com", "password3")
log_into_google("AddSession", "account@domain2.com", "password4")
tell application "Safari" to set URL of document 1 to "https://plus.google.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment