Last active
November 20, 2020 16:26
-
-
Save wonko21/c630327e993574ab8e3e6569666cc136 to your computer and use it in GitHub Desktop.
A little Script for https://bugzilla.opensuse.org/show_bug.cgi?id=1174184
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 python3 | |
# (c) 2020 Wonko21 | |
# Public Domain, No rights reserved. | |
# A little Script for https://bugzilla.opensuse.org/show_bug.cgi?id=1174184#c21 | |
# Inspired by https://gist.github.com/kaefer3000/73febe1eec898cd50ce4de1af79a332a | |
import lz4.block | |
import sys | |
import json | |
def fix_lpack(lpack): | |
if not lpack['path'].endswith('.xpi'): | |
print('Adding .xpi to path') | |
lpack['path'] += '.xpi' | |
if not lpack['rootURI'].startswith('jar:'): | |
print('Prepending jar: to rootUri') | |
lpack['rootURI'] = 'jar:'+lpack['rootURI'] | |
if not lpack['rootURI'].endswith('.xpi!'): | |
print('Adding .xpi! to rootURI') | |
lpack['rootURI'] += '.xpi!' | |
with open('addonStartup.json.lz4', "r+b") as lz4file: | |
if lz4file.read(8) != b"mozLz40\0": | |
print('Not an Mozilla lz4 file', file=sys.stderr) | |
sys.exit(2) | |
data = json.loads(lz4.block.decompress(lz4file.read())) | |
for addon in data['app-global']['addons']: | |
if addon.startswith('langpack'): | |
fix_lpack(data['app-global']['addons'][addon]) | |
lz4file.seek(0,0) | |
lz4file.write(b"mozLz40\0") | |
lz4file.write(lz4.block.compress(bytearray(json.dumps(data),'utf-8'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for your program, it fixed exactly the problem I had!
One thing to note, although all my addons were still showing enabled, they weren't actually running. For each one, I had to disable it and then enable it again in the About:addons page.
This was on OpenSuSE Tumbleweed 20200819 and Firefox 79.0.