Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Can't print the saved passwords using code posted by cor-el on 8/13/15 & modified 2/22/2018.

  • 9 replies
  • 1 has this problem
  • 23 views
  • Last reply by cor-el

more options

Tried using code from cor-el. First one worked using browser console, but second in web console gives following error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Using Mac OS 10.12.6 and Firefox 58.0.2

Need to get usable hard copy and database/spreadsheet data.

thanks

Tried using code from cor-el. First one worked using browser console, but second in web console gives following error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data Using Mac OS 10.12.6 and Firefox 58.0.2 Need to get usable hard copy and database/spreadsheet data. thanks

Chosen solution

Aha, yes, recent versions of Firefox have a fancier viewer for JSON-format files. As a result, the body now contains extra tags that you need to bypass to read out the data.

First, you still generate the same firefox-logins.json file using the Browser Console script.

Second, open the firefox-logins.json file in a Firefox tab, and pause until the viewer renders.

Third, click the "Raw Data" heading, and then run the updated script (first line modified) in the Web Console:

json = document.querySelector('pre.data').textContent;
var signons = JSON.parse(json);
var names = "";
for (var i=0; SG=signons[i]; i++) {
try {
 var host = SG.hostname||"";
 var user = SG.username||"";
 var pass = SG.password||"";
 names += "<tr><td>"+ (i+1) + "<td>" + host + "<td>" + user + "<td>" + pass;
} catch(e){}
}
var body = '<table border="1" cellspacing="0">\n'+
'<tr class="head">\n'+
'<td>#\n'+
'<td><b>Host</b>\n'+
'<td><b>User name</b>\n'+
'<td><b>Password</b>\n'+
names+
'</table>\n';
document.body.innerHTML = body;

This could be integrated with the Browser Console script if someone has time to do it so that you do not need multiple steps.

(Now I have to permanently delete firefox-logins.json from my system!)

Read this answer in context 👍 1

All Replies (9)

more options

Can you link to the thread that you're referring to?

more options

Using code in this thread: https://support.mozilla.org/en-US/questions/1077630

Code is near the end of thread. Thanks

more options

Chosen Solution

Aha, yes, recent versions of Firefox have a fancier viewer for JSON-format files. As a result, the body now contains extra tags that you need to bypass to read out the data.

First, you still generate the same firefox-logins.json file using the Browser Console script.

Second, open the firefox-logins.json file in a Firefox tab, and pause until the viewer renders.

Third, click the "Raw Data" heading, and then run the updated script (first line modified) in the Web Console:

json = document.querySelector('pre.data').textContent;
var signons = JSON.parse(json);
var names = "";
for (var i=0; SG=signons[i]; i++) {
try {
 var host = SG.hostname||"";
 var user = SG.username||"";
 var pass = SG.password||"";
 names += "<tr><td>"+ (i+1) + "<td>" + host + "<td>" + user + "<td>" + pass;
} catch(e){}
}
var body = '<table border="1" cellspacing="0">\n'+
'<tr class="head">\n'+
'<td>#\n'+
'<td><b>Host</b>\n'+
'<td><b>User name</b>\n'+
'<td><b>Password</b>\n'+
names+
'</table>\n';
document.body.innerHTML = body;

This could be integrated with the Browser Console script if someone has time to do it so that you do not need multiple steps.

(Now I have to permanently delete firefox-logins.json from my system!)

more options

This fixed the problem. Thank you!! Hope it helps someone else.

more options

I don't know how to access/write website content with multi-process enabled (i.e remote tabs) from within the Browser Console. From within the Web Console it is easy to access the content window. With multi-process disabled it is gBrowser.selectedBrowser.contentDocument.body.innerHTML from within the Browser Console.. I don't think it is worth the extra effort to setup frame script loaders and the message manager.

more options

Hi cor-el, I was thinking of the old technique of building a page, converting to dataURI, then launching in a new window or tab. Like you posted in: https://support.mozilla.org/questions/967729#answer-466640

Then the sensitive data would never touch the disk, except in the cache which is easy to clear. Or would it be in history? I guess that would need to be cleaned, too.

more options

If you use a data URI with all data in it then sessionstore will store the complete data URI and this includes a closed tab case, so I stopped using that a long time ago and changed to injecting the body text.

var dataURI = 'data:text/html;charset=utf-8,';
more options

cor-el said

If you use a data URI with all data in it then sessionstore will store the complete data URI and this includes a closed tab case, so I stopped using that a long time ago and changed to injecting the body text.

I forgot about that problem.

more options

Note that you can use the view-source: prefix (view-source:file://) in the location/address bar to get the raw code.