Advertisement
Guest User

Untitled

a guest
May 17th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set csvFile to (choose file with prompt "Select CSV file...") as text
  2.  
  3. set lns to paragraphs of (read file csvFile as «class utf8»)
  4.  
  5. # Loop over lines read and copy each to the clipboard.
  6. set oldDelimiters to AppleScript's text item delimiters
  7. set AppleScript's text item delimiters to ","
  8. set passwords_data to {}
  9. repeat with ln in lns
  10.     set row_items to every text item of ln
  11.     set end of passwords_data to row_items
  12. end repeat
  13. set AppleScript's text item delimiters to oldDelimiters
  14. set passwords_data to rest of passwords_data
  15. set passwords_data to reverse of rest of reverse of passwords_data
  16.  
  17. tell application "Safari"
  18.     activate
  19.     tell application "System Events"
  20.         tell process "Safari"
  21.             tell menu bar 1 to click menu item "Preferences…" of menu "Safari"
  22.             delay 0.5
  23.             tell window 1
  24.                 click button "Passwords" of toolbar 1
  25.                 delay 0.2
  26.                 set value of text field "Enter Password" of group 1 of group 1 to "USER_PASSWORD"
  27.                 delay 0.2
  28.                 tell application "System Events"
  29.                     keystroke return
  30.                 end tell
  31.                 delay 0.2
  32.                
  33.                 repeat with password_data in passwords_data
  34.                     log password_data
  35.                     click button "Add" of group 1 of group 1
  36.                     set value of text field 1 of sheet 1 to item 2 of password_data
  37.                     set value of text field 2 of sheet 1 to item 3 of password_data
  38.                     set value of text field 3 of sheet 1 to item 4 of password_data
  39.                     delay 0.2
  40.                     tell application "System Events"
  41.                         keystroke return
  42.                     end tell
  43.                     delay 0.2
  44.                 end repeat
  45.             end tell
  46.         end tell
  47.     end tell
  48. end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement