Add support to create crx file

This commit is contained in:
2026-02-15 09:23:11 +08:00
parent e510467197
commit ddaf11b7e1
2 changed files with 6 additions and 1 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
node_modules/
dist/
*.crx
*.pem
*.zip

View File

@@ -1,5 +1,6 @@
from zipfile import ZipFile, ZIP_DEFLATED
import os
from crx3 import creator
NEED_PACKED = [
'dist',
@@ -10,7 +11,7 @@ NEED_PACKED = [
]
def pack():
with ZipFile('bookdownload.crx', 'w', compression=ZIP_DEFLATED, compresslevel=9) as zip:
with ZipFile('bookdownload.zip', 'w', compression=ZIP_DEFLATED, compresslevel=9) as zip:
for item in NEED_PACKED:
if not os.path.exists(item):
print(f'Warning: {item} does not exist, skipping.')
@@ -21,6 +22,8 @@ def pack():
zip.write(os.path.join(foldername, filename))
else:
zip.write(item)
creator.create_crx_file('bookdownload.zip', 'bookdownload.pem', './bookdownload.crx')
os.remove('bookdownload.zip')
if __name__ == '__main__':