Forked from derjanb/extract_tampermonkey_script.py
Last active
September 28, 2018 20:29
-
-
Save sp4ce/a649517a429d72ffc442 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# 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" | |
# | |
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) | |
if m: | |
name = re.sub("[\W\d\b]", "_", m.groups()[0].strip()) | |
full_name = "%s.user.js" % name | |
print "Writing to %s" % full_name | |
content = json.JSONDecoder(encoding='UTF-8').decode(v)['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