Skip to content

Instantly share code, notes, and snippets.

@derjanb
Last active October 17, 2025 13:06
Show Gist options
  • Select an option

  • Save derjanb/9f6c10168e63c3dc3cf0 to your computer and use it in GitHub Desktop.

Select an option

Save derjanb/9f6c10168e63c3dc3cf0 to your computer and use it in GitHub Desktop.

Revisions

  1. @Kerrigan29a Kerrigan29a revised this gist Feb 9, 2016. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions extract_tampermonkey_script.py
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,10 @@
    #!/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"
    #
    # 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/"

    import leveldb
    import sys
    import re
  2. derjanb revised this gist Jan 11, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion extract_tampermonkey_script.py
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@
    for k,v in db.RangeIter():
    m = pattern.match(k)
    if m:
    name = re.sub("[\W\d\b]", "_", m.groups()[0].strip())
    name = re.sub("[\W\b]", "_", m.groups()[0].strip())
    full_name = "%s.user.js" % name

    print "Writing to %s" % full_name
  3. @sp4ce sp4ce revised this gist Oct 5, 2015. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions extract_tampermonkey_script.py
    Original file line number Diff line number Diff line change
    @@ -6,9 +6,10 @@
    import leveldb
    import sys
    import re
    import ast
    import json
    import codecs

    pattern = re.compile("(.*)@source$")
    pattern = re.compile("^@source(.*)$")

    db = leveldb.LevelDB(sys.argv[1:][0])

    @@ -20,6 +21,7 @@

    print "Writing to %s" % full_name

    text_file = open(full_name, "w")
    text_file.write(ast.literal_eval(v))
    text_file.close()
    content = json.JSONDecoder(encoding='UTF-8').decode(v)['value']

    with codecs.open(full_name, 'w', 'utf-8') as text_file:
    text_file.write(content)
  4. derjanb created this gist Sep 3, 2015.
    25 changes: 25 additions & 0 deletions extract_tampermonkey_script.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    #!/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 ast

    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

    text_file = open(full_name, "w")
    text_file.write(ast.literal_eval(v))
    text_file.close()