::#mkdir ddlog 
::https://antizapret.prostovpn.org/proxy.pac
echo "print 'qq';" | perl -lne
set pp="sessionstore.js"
perl -lne "print for /url\":\"\K\[^\"\]+/g" %pp%
pause
exit
rem D:\tools
rem ls -R > zzbbnc.txt
rem pwd > tmx3.c
#set path=e:/lcc/bin
lc tmx3.c
cp ftes01.pl ftes01a.pl
//////////
files = path.glob('*default*/sessionstore-backups/recovery.js*')

try:
    template = sys.argv[1]
except IndexError:
    template = '%s (%s)'

for f in files:
    b = f.read_bytes()
    if b[:8] == b'mozLz40\0':
        b = lz4.block.decompress(b[8:])
    j = json.loads(b)
    for w in j['windows']:
        for t in w['tabs']:
            i = t['index'] - 1
            print(template % (
                t['entries'][i]['title'],
                t['entries'][i]['url']
                ))
////////////


If you're a Ubuntu user, or similar, you should be able to find the latest backup at

~/.mozilla/firefox/ro51nwle.default/sessionstore-backups/upgrade.jsonlz4-[timestamp of upgrade]
I didn't know anything about the file format, but this gist was basically enough to get me started

With the gist saved to the backup folder, you can export to json with:

$ sudo pip3 install lz4
$ python3 ./mozlz4a.py -d upgrade.jsonlz4-[timestamp of backup] backup.js
There's a lot of data in there (including each tab's entire history) but at least it's not lost!

If you just want to save the most recent url from each tab like I did, something like the following python should do the job:

////////////////////////////

#!/usr/bin/env python3

import json

with open('backup.js') as infile:
    read_data = infile.read()

json_data = json.loads(read_data)

tab_groups = json.loads(json_data['windows'][0]['extData']['tabview-group'])

groups = {int(k): {'title': tab_groups[k]['title'], 'tabs': []} for k in tab_groups.keys()}

for tab in json_data['windows'][0]['tabs']:
    url = tab['entries'][-1]['url']
    group_id = json.loads(tab['extData']['tabview-tab'])['groupID']
    groups[group_id]['tabs'].append(url)

with open('tabs_backup.json', 'w') as outfile:
    json.dump(groups, outfile, indent=4)                    

/////////////////////////////
#!/usr/bin/env python3
# Count open tabs from a firefox profile
# Working directory is the root of a Firefox profile.
import json
j = json.loads(open("sessionstore.js", 'rb').read().decode('utf-8'))
def info_for_tab(tab):
    try:
        return (tab['entries'][0]['url'], tab['entries'][0]['title'])
    except IndexError:
        return None
    except KeyError:
        return None
def tabs_from_windows(window):
    return list(map(info_for_tab, window['tabs']))
all_tabs = list(map(tabs_from_windows, j['windows']))
print('Statistics: {wins} windows, {tabs} total tabs'.format(wins=len(all_tabs), tabs=sum(map(len, all_tabs))))
///////////////////////
import json\n
f = open("/home/username/.mozilla/firefox/RANDOM.profile/sessionstore.js", "r")\n
jdata = json.loads(f.read())\nf.close()\n
for win in jdata.get("windows"):\n
\tfor tab in win.get("tabs"):\n
\t\ti = tab.get("index") - 1\n
\t\tprint tab.get("entries")[i].get("url")
/////////////////////////
python -c '
import io, json, pathlib as p
fpath = next(iter(p.Path("~/.mozilla/firefox").expanduser().glob("*.default/sessionstore-backups/recovery.js*")))
with io.open(fpath, "rb") as fd:
    if fpath.suffix == ".jsonlz4":
        import lz4.block as lz4
        fd.read(8)  # b"mozLz40\0"
        jdata = json.loads(lz4.decompress(fd.read()).decode("utf-8"))
    else:
        jdata = json.load(fd)
    for win in jdata.get("windows"):
        for tab in win.get("tabs"):
            i = tab["index"] - 1
            print(tab["entries"][i]["url"])
'
/////////////////////
export opentabs=$(find ~/.mozilla/firefox*/*.default/sessionstore-backups/recovery.jsonlz4);

python3 <<< $'import os, json, lz4.block
f = open(os.environ["opentabs"], "rb")
magic = f.read(8)
jdata = json.loads(lz4.block.decompress(f.read()).decode("utf-8"))
f.close()
for win in jdata["windows"]:
    for tab in win["tabs"]:
        i = int(tab["index"]) - 1
        urls = tab["entries"][i]["url"]
        print(urls)'
//////////////////
<?php
{
 // Make sure we have the correct number of args
 $args = $_SERVER['argv'];
 if (2 != $_SERVER['argc']) {
   echo "Format: $args[0] <filename>\n";
   exit(-1);
 }
 $filename = $args[1];

 // Read the input file into a json string
 $jsonStore = file_get_contents($filename) or die("Failed to open input file");

 // Convert the json string into an object
 $store = json_decode($jsonStore);

 // Create an output .html file
 $file = fopen("$filename.html", "w") or die("Failed to create output file");

 // Add HTML header
 fwrite($file, "<html><body><ul>\n");

 // Parse the session store object and generate HTML links for each tab.
 // Session stores have windows->tabs->entries array-of-arrays structure.
 $windows = $store->windows;
 foreach ($windows as $window) {
   $tabs = $window->tabs;
   foreach ($tabs as $tab) {
     $entries = $tab->entries;
     foreach ($entries as $entry) {
       fwrite($file, "<li><a href="$entry->url">$entry->title</a>\n");
     }
   }
 }

 // Add HTML footer
 fwrite($file, "</ul></body></html>\n");

 // Close the output file
 fclose($file);
}
//////////////////
import json f = open("sessionstore.bk.json") data=json.load(f) # print a list of top-level JSON entries for key in data: print key 
//////////////////
cat sessionstore.bk.json | python -m json.tool > sessionstore.pretty.json 
/////////////////
Then find the previously copied file sessionstore.js and rename it into sessionstore.txt.
Open this file in the browser (Firefox->New tab ->Open file, specify the path to the txt file).
Run Firebug console (Firefox->Web Development->Firebug-> Open Firebug)
In the bottom of the window there is a console prompt (it is marked with the red rectangle on the screenshot). Copy the next js-code into it: javascript:(function(){var D=document,H,i=j=0,P=D.getElementsByTagName('PRE'),t='',R=/[^:]\{"entries":\[\{("url":"([^"]*)")\,("title":"([^"]*)"){0,1}/g,T,U;for(j=0;E=P[j];j++){H=E.innerHTML;while(R.exec(H)){U=RegExp.$2;T=RegExp.$4;if(T.length==0){T=U;}t+='<b>['+(++i)+']</b> <a href='+U+'>'+T+' ('+U+')<\/a><br>';}}with(window.open().document){write(t);close()}})(); And press Enter.
////////////////
