Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
my dumb 1password text file exporter. fuck applescript.
set commonScript to load script alias ¬
((path to library folder from user domain as string) ¬
& "Scripts:CommonCode.scpt")
set filesavepath to path to desktop
set filesavepath to POSIX path of filesavepath & "1PasswordPlaintextArchive/"
repeat 170 times
set randomString to ""
repeat with x from 1 to 8
set randomChar to ASCII character (random number from 97 to 122)
set randomString to randomString & randomChar
end repeat
activate application "1Password"
tell application "System Events"
tell process "1Password"
select row 1 of table 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of window "1Password"
set loginItemName to value of static text 1 of row 1 of table 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of window "1Password"
click menu item "Text File…" of menu 1 of menu item "Export Selected" of menu 1 of menu bar item "File" of menu bar 1
tell window "Export Text File"
click button "Export…"
keystroke "g" using {command down, shift down}
repeat until exists sheet 1
delay 0.5
end repeat
tell sheet 1
keystroke filesavepath
delay 1
click button "Go" of sheet 1
end tell
end tell
set finalFileName to loginItemName & "-" & randomString & ".txt"
set value of text field 1 of sheet 1 of window "Export Text File" to finalFileName
click button "Export" of sheet 1 of window "Export Text File"
end tell
end tell
log_event("Saved: " & finalFileName) of commonScript
delay 1
activate application "1Password"
tell application "System Events"
tell process "1Password"
delay 1
select row 1 of table 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of window "1Password"
delay 1
click menu item "Quick Delete" of menu 1 of menu bar item "Edit" of menu bar 1
log_event("Deleted: " & finalFileName) of commonScript
end tell
end tell
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment