Created
October 31, 2019 18:07
-
-
Save sneak/74dfcf36e3ebaf176f62770fe1ce5c28 to your computer and use it in GitHub Desktop.
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
-- open new textedit document | |
-- open safari, open prefs, go to password list view and enter password/unlock | |
-- run this script | |
-- credit to Joseph Rees, MrC, pken, nickhass | |
-- | |
-- if it fails, stop everything, put the selection in textedit on a new line, put the safari pw selection on the last good item in the textedit file, and rerun | |
-- does not get the first entry in the list, didn't feel like fixing it | |
set x to 1 | |
repeat while (x ≤ 5000) | |
-- Switch To Safari -- | |
tell application "Safari" | |
activate | |
delay 0.5 | |
tell application "System Events" | |
-- Switch from search field to password list field (Only needs to be done once) -- | |
-- Select first password in list (Field selected. but nothing highlighted) -- | |
key code 125 | |
delay 0.1 | |
-- Open Right-click Menu -- | |
tell application process "Safari" | |
set _selection to value of attribute "AXFocusedUIElement" | |
tell _selection to perform action "AXShowMenu" | |
end tell | |
-- Down arrow once to choose/highlight "Copy Website" -- | |
key code 125 | |
delay 0.1 | |
-- Copy Website/URL data -- | |
keystroke return | |
delay 0.1 | |
end tell | |
end tell | |
-- Switch To TextEdit | |
tell application "TextEdit" | |
activate | |
delay 0.1 | |
tell application "System Events" | |
-- Print a double quote -- | |
keystroke "\"" | |
delay 0.1 | |
-- Paste "Website/URL" data to text file -- | |
keystroke "v" using command down | |
delay 0.1 | |
-- Print ending double quote and a comma for CSV -- | |
keystroke "\"," | |
delay 0.1 | |
-- Print a double quote -- | |
keystroke "\"" | |
delay 0.1 | |
-- Paste "Websites" data to text file again (For "Title" field in 1Password) -- | |
keystroke "v" using command down | |
delay 0.1 | |
-- Print ending double quote and a comma for CSV -- | |
keystroke "\"," | |
delay 0.1 | |
end tell | |
end tell | |
-- Switch To Safari -- | |
tell application "Safari" | |
activate | |
delay 0.1 | |
tell application "System Events" | |
-- Open Window containing "User Name", "Password" and "Websites" fields -- | |
keystroke return | |
delay 0.1 | |
-- Move to "User Name" field -- | |
keystroke tab | |
delay 0.1 | |
-- Copy data from "User Name" field -- | |
keystroke "c" using command down | |
delay 0.1 | |
end tell | |
end tell | |
-- Switch To TextEdit -- | |
tell application "TextEdit" | |
activate | |
delay 0.1 | |
tell application "System Events" | |
-- Print a double quote -- | |
keystroke "\"" | |
delay 0.1 | |
-- Paste "User Name" data to text file -- | |
keystroke "v" using command down | |
delay 0.1 | |
-- Print ending double quote and a comma for CSV -- | |
keystroke "\"," | |
delay 0.1 | |
end tell | |
end tell | |
-- Switch To Safari -- | |
tell application "Safari" | |
activate | |
delay 0.1 | |
tell application "System Events" | |
-- Move to "Password" field -- | |
keystroke tab | |
delay 0.1 | |
-- Copy from "Password" field -- | |
keystroke "c" using command down | |
delay 0.1 | |
end tell | |
end tell | |
-- Switch To TextEdit -- | |
tell application "TextEdit" | |
activate | |
delay 0.1 | |
tell application "System Events" | |
-- Print a double quote -- | |
keystroke "\"" | |
delay 0.1 | |
-- Paste "Websites" data to text file -- | |
keystroke "v" using command down | |
delay 0.1 | |
-- Print ending double quote and start a new line -- | |
keystroke "\"" | |
keystroke return | |
end tell | |
end tell | |
-- Switch To Safari -- | |
tell application "Safari" | |
activate | |
delay 0.1 | |
tell application "System Events" | |
-- Click "Done" button -- | |
keystroke return | |
delay 0.1 | |
end tell | |
end tell | |
set x to (x + 1) | |
end repeat | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment