Last active
August 4, 2025 07:11
-
-
Save derjanb/9f6c10168e63c3dc3cf0 to your computer and use it in GitHub Desktop.
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/" | |
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\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) |
Hi @iamqiz, is it possible that you could help me recover my scripts?
I had an issue with Windows that forced me to reinstall Chrome, and unfortunately, after reinstalling, all my Tampermonkey scripts were lost. I had been collecting those scripts for years, and I would really appreciate any help you can provide to recover them.
Thanks in advance!
@guillmz read my comment above. If you didn't back up the folder AppData\Local\Chrome
, then you can't recover them, because your chrome installation probably overrode the folder I mentioned above, especially if you installed tampermonkey again and those scripts are not there.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For those who just want to copy tampermonkey scripts from one Chrome browser to another, you don't need scripts to just copy the scripts to another browser.
Copy folder
C:\Users\YourUserName\AppData\Local\Vivaldi\User Data\Default\Local Extension Settings\dhdgffkkebhmkfjojejmpbldmpobfkfo
. If the extension id changes when you will want to do it, look it up in the extension list.