Last active
April 29, 2024 23:29
-
-
Save derjanb/9f6c10168e63c3dc3cf0 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 | |
# 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) |
@iamqiz 佬,我把位于C:\Users\用户名\AppData\Local\Microsoft\Edge\User Data\Default\Extensions里的油猴插件拖出来后,油猴脚本消失了,这种情况可以恢复脚本吗?
@ziqian-L 油猴数据位于 "C:\Users<USERNAME>\AppData\Local\Microsoft\Edge\User Data\Default\Local Extension Settings\<EXTENSION_ID> 下, 如果有CURRENT *.ldb 等文件,那么可以恢复, 我的仓库可以在线恢复,不需要自己搭python环境 ,见: https://github.com/iamqiz/github-action-for-tapermonkey
谢谢大佬的解答,由于我在插件失效后将油猴重新安装了一遍,导致里面数据被覆盖了,已经找不回来了。
…---- 回复的原邮件 ----
| 发件人 | ***@***.***> |
| 日期 | 2023年04月12日 09:19 |
| 收件人 | ***@***.***> |
| 抄送至 | ***@***.***> |
| 主题 | Re: derjanb/extract_tampermonkey_script.py |
@iamqiz commented on this gist.
@ziqian-L 油猴数据位于 "C:\Users<USERNAME>\AppData\Local\Microsoft\Edge\User Data\Default\Local Extension Settings<EXTENSION_ID> 下, 如果有CURRENT *.ldb 等文件,那么可以恢复, 我的仓库可以在线恢复,不需要自己搭python环境 ,见: https://github.com/iamqiz/github-action-for-tapermonkey
—
Reply to this email directly, view it on GitHub or unsubscribe.
You are receiving this email because you were mentioned.
Triage notifications on the go with GitHub Mobile for iOS or Android.
@ziqian-L 😂 以后定期做好备份吧 ,设置>实用工具>压缩包|文件> 导出
已经整上谷歌云服务备份了😂谢谢佬抽时间解答
…---- 回复的原邮件 ----
| 发件人 | ***@***.***> |
| 日期 | 2023年04月12日 21:59 |
| 收件人 | ***@***.***> |
| 抄送至 | ***@***.***> |
| 主题 | Re: derjanb/extract_tampermonkey_script.py |
@iamqiz commented on this gist.
@ziqian-L😂 以后定期做好备份吧 ,设置>实用工具>压缩包|文件> 导出
—
Reply to this email directly, view it on GitHub or unsubscribe.
You are receiving this email because you were mentioned.
Triage notifications on the go with GitHub Mobile for iOS or Android.
Is there something like this for Firefox?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! thanks a bunch