-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathff_tabs_list_in
More file actions
executable file
·58 lines (45 loc) · 1.31 KB
/
ff_tabs_list_in
File metadata and controls
executable file
·58 lines (45 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /usr/bin/env python3
import platform
import sys
import pathlib
import lz4.block
import json
def help():
print(
"""
usage: ff_tabs_list_in recovery_file [output_template]
List all Firefox tabs with title and URL
Supported input: json or jsonlz4 recovery files
Default output: title (URL)
Output format can be specified as argument
Example:
ff_tabs_list_in ~/.mozilla/firefox/1du5sdlg.default-esr/sessionstore-backups/recovery.jsonlz4 '<a href="%(url)s">%(title)s</a>'
Based on https://gist.github.com/tmonjalo/33c4402b0d35f1233020bf427b5539fa
"""
)
exit(1)
try:
recover_file_path = sys.argv[1]
except IndexError:
recover_file_path = "--help"
if recover_file_path == "--help":
help()
path = pathlib.Path(recover_file_path)
try:
template = sys.argv[2]
except IndexError:
template = '%(title)s %(url)s'
b = path.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
if len(t['entries']) > i:
print(template % {
'title': t['entries'][i]['title'],
'url': t['entries'][i]['url']
} )
# print '<a href="%(url)s">%(url)s</a>' % {'url': my_url}