Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set csvFile to (choose file with prompt "Select CSV file...") as text
- set lns to paragraphs of (read file csvFile as «class utf8»)
- # Loop over lines read and copy each to the clipboard.
- set oldDelimiters to AppleScript's text item delimiters
- set AppleScript's text item delimiters to ","
- set passwords_data to {}
- repeat with ln in lns
- set row_items to every text item of ln
- set end of passwords_data to row_items
- end repeat
- set AppleScript's text item delimiters to oldDelimiters
- set passwords_data to rest of passwords_data
- set passwords_data to reverse of rest of reverse of passwords_data
- tell application "Safari"
- activate
- tell application "System Events"
- tell process "Safari"
- tell menu bar 1 to click menu item "Preferences…" of menu "Safari"
- delay 0.5
- tell window 1
- click button "Passwords" of toolbar 1
- delay 0.2
- set value of text field "Enter Password" of group 1 of group 1 to "USER_PASSWORD"
- delay 0.2
- tell application "System Events"
- keystroke return
- end tell
- delay 0.2
- repeat with password_data in passwords_data
- log password_data
- click button "Add" of group 1 of group 1
- set value of text field 1 of sheet 1 to item 2 of password_data
- set value of text field 2 of sheet 1 to item 3 of password_data
- set value of text field 3 of sheet 1 to item 4 of password_data
- delay 0.2
- tell application "System Events"
- keystroke return
- end tell
- delay 0.2
- end repeat
- end tell
- end tell
- end tell
- end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement