Scripts to export passwords from Safari 14? On Mac OS X [Solved]

earlbaugh
earlbaugh
Community Member
edited June 2021 in Mac

There are or were scripts to export passwords from Safari, but trying them on Safari 14 (OS X Catalina) don't seem to work.
I was wondering if there are updated version that work with that combination? (just trying to export some long term passwords from it and finally stop it from duplicating what I have in 1Password.


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Sync Type: Not Provided
Referrer: forum-search:Exporting passwords from Safari 14

Comments

  • MrC
    MrC
    Volunteer Moderator

    @earlbaugh

    Which script are you referring to?

  • earlbaugh
    earlbaugh
    Community Member

    The mrc-converter-suite-2020-04-22-1730.zip package. It's got a number of scripts... I'm trying to find a Get_Safari12_Passwords.applescript that is for Safari 14. (this one is obviously for Safari12...)

  • MrC
    MrC
    Volunteer Moderator
    edited October 2020

    @earlbaugh

    That's the script you want to use - it is good for version 12 and up. Can you tell me what the issue / error is?

    Be sure to quit Safari, let the script open it for you, and while the script is running, leave your Mac alone until it finishes.

    You can follow along with the video where I show the process.

  • earlbaugh
    earlbaugh
    Community Member

    Ok, first, I was thinking this would need to be updated (given the much different Safari 14). And I didn't catch that Safari needed to be shut down before I started (that's when it gave the error). I just followed your instructions and now have exported passwords!

    Thanks!!

  • earlbaugh
    earlbaugh
    Community Member

    Spoke too soon... just went to open the file. It's empty.... had the headers but no data...

    Thoughts?

  • earlbaugh
    earlbaugh
    Community Member

    Ok, so again too soon. I figured out that I have to wait for the passwords to show up before hitting continue (after entering the password to unlock them). It seems to be cranking along. I'll try this and let you know... thanks again...

  • ag_ana
    ag_ana
    1Password Alumni

    Thank you for the update @earlbaugh! Let us know how it goes :)

  • jcklaus
    jcklaus
    Community Member

    Hi - I've been trying to use the script to export my Safari passwords from Safari 14.0.2, but every time I get a script error message - System Events got an error: Script Editor is not allowed to send keystrokes.

  • MrC
    MrC
    Volunteer Moderator

    @jcklaus

    You need to set Security & Privacy settings to allow this. See this post.

    After you've enabled the setting shown at the post above, you can watch a screen video showing how the process works here.

    I'm here if you need additional guidance.

  • jcklaus
    jcklaus
    Community Member

    Thank you so so much for getting back so quickly! Worked fine after that!

  • MrC
    MrC
    Volunteer Moderator

    You're very welcome. Good to see it worked for you, @jcklaus ,

    Enjoy 1Password!

  • 11Rick23
    11Rick23
    Community Member

    Hello, I'm having a problem……
    When I download the file, some of the letters change into a different one (garbled).
    So I tried fixing all those letters, such as "イ" to "=" and "¥" to "\".

    Then the programmed worked, but not successfully.
    It seems to be working until the actual "outputting password" part, which gives me "The password table appears to be empty" error.

    Is the program still working? and how can I fix this problem?

    thanks!

    P.S.
    safari version: 14.1.1

  • MrC
    MrC
    Volunteer Moderator
    edited June 2021

    Sorry, @11Rick23 - which file are you referring to?

    Let me take a guess that it is the Get_Safari12_Passwords script you are referring to.

    But what I don't understand is "When I download the file, some of the letters change into a different one (garbled)." Can you describe this more?

  • 11Rick23
    11Rick23
    Community Member

    Yes, i’m referring to that script.
    When i downloaded the file from the dropbox, the script didn’t work due to some errors.
    I found out that some of the letters are garbled.
    So I fixed this error by changing some of the letters.

    In on my phone now, so I’ll put some screenshots when i get back on my mac.

  • ag_ana
    ag_ana
    1Password Alumni

    Thank you @11Rick23, some screenshots will definitely be useful :+1:

  • 11Rick23
    11Rick23
    Community Member

    Sorry it's Japanese.

    There are 2 types of errors.
    Identifier error can be fixed by changing "¥" mark to "\".
    Unknown Token error can be fixed by changing "イ" to "=".

    But it gives me "The password table appears to be empty", though it's not.

    Thanks!

  • 11Rick23
    11Rick23
    Community Member
  • MrC
    MrC
    Volunteer Moderator
    edited June 2021

    @11Rick23

    Sorry for the delay - I received the notification of your post late last night, and could not investigate this issue until this morning.

    I'm confused by the character set differences of what is included in the converter suite zip archive, which is:

    $ file -b mrc-converter-suite/Get_Safari12_Passwords.applescript
    ISO-8859 text
    

    and yours is:

    $ file -b Original,\ not\ working\ program.scpt
    UTF-8 Unicode text, with CRLF line terminators
    

    In either case, I was suspecting your macOS language was not set to English, and I'd recently made changes to accommodate non-English languages. Please try the Get_Safari12_Passwords converter that I've posted under the Custom folder at the converter suite dropbox location. I had to remove some English references to menu items and replace them with specific UI component names. It worked for me in both English and French, but I'll need others to let me know if it works for them in languages other than those.

  • 11Rick23
    11Rick23
    Community Member

    Yes, it still gives me errors…… it gives me errors on line 97, for example. (it's the same error as mentioned above)

  • MrC
    MrC
    Volunteer Moderator

    @11Rick23

    I'm not sure what's going on.

    Line 97 is just a final informational dialog. Getting an error there just means you've left the dialog open for more than several minutes w/out pressing OK. That's not an issue, and by then the script is done doing any work.

    It's possible that if your system is slow, and Safari is slow to open and populate the passwords table, and it's taking longer than 10 seconds, you may have to increase the property at the top of the script:

    property maxAttempts : 10
    

    This is the number of tries, once per second, that the script will try to see if Safari has filled in the password data in the password dialog's table. Look to see how long it takes Safari to fill in your table, and then set the maxAttempts property to a bit longer than that.

    If this doesn't help, there may be still some issues with non-English languages. I'm clueless about Japanese, so I'm not sure what else I can advise.

  • 11Rick23
    11Rick23
    Community Member

    No, I can’t even run the command using the original script…
    Here's a quick video of showing what I mean.
    Don't mind my glitched cursor...

  • MrC
    MrC
    Volunteer Moderator
    edited June 2021

    @11Rick23

    We need to establish a baseline to figure out why during or after downloading the script, your system or systems are converting it to a different file encoding format.

    The original script, as included in the mrc-converter-suite, contains different byte sequences than you presented to me as the "Original" script. In fact, it was not the original script:

    1. The original script has LF (hex 0a) as the line endings. Yours has CR LF (hex 0d 0a). This is typical of Windows systems.
    2. The original script escapes double quotes in strings with a backslash and a double quote. This sequence is 5c 22 hex (ASCII \ and "). Yours has this sequence changed to hex c2 a5 22. "c2 a5" is not valid UTF-8, 22 is the double quote. In fact, it is valid UTF-16BE. This is not UTF-8, and AppleScript expects scripts to be in UTF-8.

    The original script was saved as "ISO-8859 text" (e.g Mac Roman), and that was my mistake (due to an updated AppleScript debugger/editor I was using to save the file out as text). Regardless, this was incorrectly converted on your system. Since I see the CR LF line terminator mentioned above, I'm suspecting you've opened (or handled) this in some other editor, perhaps on Windows. There is some step you are taking that is not being mentioned here.

    Furthermore, some of the characters you replaced in the script are incorrect. You've changed operators like "less than or equal to" to "equal to" (e.g. instead of <= you have =). This of course will cause the script to fail. The lines pointed to by the red arrows are incorrect:

    The updated script in Custom was correctly saved as UTF-8. But that won't matter until we understand how you are performing the download, and dealing with the script file, since what you have been doing is botching the script's encoding, and furthermore, your script edits are incorrect.

    If we cannot establish this baseline that you are working with the bits that I provide, we'll never make progress.

  • 11Rick23
    11Rick23
    Community Member
    edited June 2021

    Ooh, so changing “=” to “<=” will probably make it work?

    I’m not sure why my file changes during/after I download the file… and I never opened this file on Windows.

    I don’t have any kind of auto-converter or something, and I’m using the normal “Apple Script” app to open/run the script.

    I’m not sure what CR LF is, but I’m pretty sure that line endings were converted to CR LF line endings when I uploaded it to PasteBin.

    I’m sorry that I incorrectly changed broken letters to “=” not “<=”, but I had no way to know that it was “<=”… I never saw the original file.

    I’m guessing that it breaks the code when I download the file, probably because of my default language.

    I never experienced something like this before, though.

  • MrC
    MrC
    Volunteer Moderator

    @11Rick23

    I was in the middle of typing a reply when our power went out. I placed a new converter in the Custom folder for you. Please try this … the file name includes your name, so you will know which one to download.

  • 11Rick23
    11Rick23
    Community Member

    Thank you! the one you had sent me worked just fine!

  • MrC
    MrC
    Volunteer Moderator

    Outstanding, @11Rick23 !

    Your perseverance paid off, causing me to Investigate the issues more deeply.

  • MrC
    MrC
    Volunteer Moderator

    @11Rick23

    Just a quick follow-up. Sorry about the terse reply yesterday, as I was in the process to reply to each of your questions and comments above, when the power went out (and it stayed out for another 5 hours). Fortunately I was able to finish uploading the updated test script for you.

    In a nutshell, the issue was that Script Editor and the script debugger I'm using were not offering to export the script file in a format that would work for your region / character set. I had to place a 4-byte Unicode character into the script, and then Script Editor would allow saving as UTF-16. This is what you needed. A few AppleScript-used operator characters are available in Western language character sets, but in yours, they require UTF-16 as they do not map the same way.

    The good news is that your issue forced me to understand and resolve the character issue, update the README, retire the old Get_Safari11_Passwords script, add some Safari version checking into the scripts, include the now updated and newly-named Get_Safari_Passwords, and finally I've updated the older help video that shows the entire process from unzip to 1Password import.

    So, thank you for being so patient, and providing me with the motivation to get these To Do items off my plate!

  • 11Rick23
    11Rick23
    Community Member

    No it’s all right, I’m really happy about the results and your quick replies! I didn’t thought I could resolve this issue so fast. Thank you very much :)

  • ag_ana
    ag_ana
    1Password Alumni

    Indeed, thank you @MrC for all the help :)

This discussion has been closed.