Created
August 1, 2020 05:12
-
-
Save Aceralon/d94a562840b858adc8585d7e44cbaa96 to your computer and use it in GitHub Desktop.
Modified version to work on python3 using WSL for Windows(and Edge) user. Modified from https://gist.github.com/derjanb/9f6c10168e63c3dc3cf0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Linux usage: ./extract_tampermonkey_script.py "/home/<USER>/.config/<BROWSER>/Default/Local Extension Settings/<EXTENSION_ID>" | |
# i.e.: ./extract_tampermonkey_script.py "/home/foo/.config/google-chrome-beta/Default/Local Extension Settings/gcalenpjmijncebpfijmoaglllgpjagf" | |
# Mac usage: ./extract_tampermonkey_script.py "/Users/<USER>/Library/Application Support/Google/Chrome/Default/Local Extension Settings/<EXTENSION_ID>/" | |
# i.e.: ./extract_tampermonkey_script.py "/Users/foo/Library/Application Support/Google/Chrome/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo/" | |
#Windows usage: ./extract_tampermonkey_script.py "/mnt/c/<USER>/AppData/Local/Google/Chrome/Default/Local Extension Settings/<EXTENSION_ID>/" | |
# i.e.: ./extract_tampermonkey_script.py "/mnt/c/<USER>/AppData/Local/Google/Chrome/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo/" | |
# For Microsoft edge replace /Google/Chrome with /Microsoft/Edge/User Data | |
import leveldb | |
import sys | |
import re | |
import json | |
import codecs | |
pattern = re.compile("^@source(.*)$") | |
db = leveldb.LevelDB(sys.argv[1:][0]) | |
for k, v in db.RangeIter(): | |
m = pattern.match(k.decode('utf-8')) | |
if m: | |
name = re.sub("[\W\b]", "_", m.groups()[0].strip()) | |
full_name = "%s.user.js" % name | |
print("Writing to %s" % full_name) | |
content = json.JSONDecoder().decode(v.decode('utf-8'))['value'] | |
with codecs.open(full_name, 'w', 'utf-8') as text_file: | |
text_file.write(content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment