This guide explains how to package the GenresFox extension into .crx format for distribution.
- Chrome or Edge browser installed
- The
srcfolder containing all extension files
This is the easiest and most reliable method:
-
Open Chrome/Edge and navigate to
chrome://extensions/ -
Enable Developer mode
- Toggle the "Developer mode" switch in the top right corner
-
Click "Pack extension"
- This button appears when Developer mode is enabled
-
Select extension root directory
- Click "Browse" and select the
srcfolder from this project - Example:
G:\GenresFox-NEWTAB\src
- Click "Browse" and select the
-
Private key file (optional)
- First-time packaging: Leave this field blank
- Chrome will generate a new private key file (
.pem) - Save this
.pemfile securely for future updates
- Chrome will generate a new private key file (
- Updating existing extension: Select your existing
.pemfile- This ensures the extension ID remains the same
- First-time packaging: Leave this field blank
-
Click "Pack Extension"
- Chrome will create two files:
src.crx- The packaged extension (this is what you need)src.pem- The private key (keep this secure for updates)
- Chrome will create two files:
-
Rename the output file (optional)
- The default name is
src.crx - You can rename it to
GenresFox-v0.4.5.crxor similar
- The default name is
# Run the packaging script
.\package.ps1
# Or specify custom output name
.\package.ps1 -OutputName "GenresFox-v0.4.5.crx"package.bat# Make script executable (first time only)
chmod +x package.sh
# Run the packaging script
./package.sh
# Or specify custom output name
./package.sh GenresFox-v0.4.5.crxNote: The automated scripts primarily provide instructions and create backup ZIP files. For actual .crx creation, use Method 1 (Chrome's built-in packager).
If you have Node.js installed, you can use the crx package:
# Install crx globally
npm install -g crx
# Package the extension
crx pack src -o GenresFox-v0.4.5.crxAfter packaging, you should have:
GenresFox-NEWTAB/
├── src/ # Source files (do not distribute)
├── src.crx # Packaged extension (distribute this)
├── src.pem # Private key (keep secure, do not distribute)
└── ...
- Never share your
.pemfile publicly - Keep it secure and backed up
- You need the same
.pemfile to update the extension - If you lose the
.pemfile, you'll need to create a new extension (new ID)
- The extension ID is derived from the private key
- Using the same
.pemfile ensures the same extension ID - Different
.pemfiles = different extension IDs
- Distribute:
.crxfile - Do NOT distribute:
src.pem(private key)src/folder (source code - unless open source)
- Open
chrome://extensions/ - Enable "Developer mode"
- Drag and drop the
.crxfile into the extensions page - Or click "Load unpacked" and select the
srcfolder (for development)
- Chrome Web Store: Upload the
.crxfile through the developer dashboard - Direct Distribution: Users can install by dragging the
.crxfile tochrome://extensions/- Note: Chrome may show a warning for extensions not from the Web Store
- Ensure all required files are in the
srcfolder - Check that
manifest.jsonis valid JSON - Verify all referenced files exist
- Use the same
.pemfile that was used for the original packaging - Or leave blank to create a new extension
- This happens if you use a different
.pemfile - Use the original
.pemfile to maintain the same ID
Current version: 0.4.5
The version number is defined in:
src/manifest.json- Extension versionsrc/config-manager.js- Configuration versionsrc/newtab.html- Displayed version
Make sure all version numbers match before packaging!
本指南说明如何将 GenresFox 扩展打包为 .crx 格式用于分发。
- 已安装 Chrome 或 Edge 浏览器
- 包含所有扩展文件的
src文件夹
这是最简单可靠的方法:
-
打开 Chrome/Edge 并访问
chrome://extensions/ -
启用开发者模式
- 在右上角切换"开发者模式"开关
-
点击"打包扩展程序"
- 启用开发者模式后会出现此按钮
-
选择扩展根目录
- 点击"浏览",选择项目中的
src文件夹 - 示例:
G:\GenresFox-NEWTAB\src
- 点击"浏览",选择项目中的
-
私钥文件(可选)
- 首次打包:将此字段留空
- Chrome 会生成新的私钥文件(
.pem) - 请安全保存此
.pem文件以供将来更新使用
- Chrome 会生成新的私钥文件(
- 更新现有扩展:选择您现有的
.pem文件- 这确保扩展 ID 保持不变
- 首次打包:将此字段留空
-
点击"打包扩展程序"
- Chrome 将创建两个文件:
src.crx- 打包的扩展(这是您需要的)src.pem- 私钥(请安全保存用于更新)
- Chrome 将创建两个文件:
-
重命名输出文件(可选)
- 默认名称是
src.crx - 您可以将其重命名为
GenresFox-v0.4.5.crx或类似名称
- 默认名称是
# 运行打包脚本
.\package.ps1
# 或指定自定义输出名称
.\package.ps1 -OutputName "GenresFox-v0.4.5.crx"package.bat# 添加执行权限(仅首次需要)
chmod +x package.sh
# 运行打包脚本
./package.sh
# 或指定自定义输出名称
./package.sh GenresFox-v0.4.5.crx注意:自动化脚本主要提供说明并创建备份 ZIP 文件。要创建实际的 .crx 文件,请使用方法 1(Chrome 内置打包工具)。
如果您已安装 Node.js,可以使用 crx 包:
# 全局安装 crx
npm install -g crx
# 打包扩展
crx pack src -o GenresFox-v0.4.5.crx打包后,您应该有以下文件:
GenresFox-NEWTAB/
├── src/ # 源文件(不要分发)
├── src.crx # 打包的扩展(分发此文件)
├── src.pem # 私钥(安全保存,不要分发)
└── ...
- 永远不要公开分享您的
.pem文件 - 请安全保存并备份
- 更新扩展时需要相同的
.pem文件 - 如果丢失
.pem文件,您需要创建新扩展(新 ID)
- 扩展 ID 由私钥派生
- 使用相同的
.pem文件可确保相同的扩展 ID - 不同的
.pem文件 = 不同的扩展 ID
- 分发:
.crx文件 - 不要分发:
src.pem(私钥)src/文件夹(源代码 - 除非是开源项目)
- 打开
chrome://extensions/ - 启用"开发者模式"
- 将
.crx文件拖放到扩展页面 - 或点击"加载已解压的扩展程序"并选择
src文件夹(用于开发)
- Chrome 网上应用店:通过开发者控制台上传
.crx文件 - 直接分发:用户可以通过将
.crx文件拖到chrome://extensions/来安装- 注意:Chrome 可能会对非来自应用店的扩展显示警告
- 确保
src文件夹中包含所有必需文件 - 检查
manifest.json是否为有效的 JSON - 验证所有引用的文件是否存在
- 使用用于原始打包的相同
.pem文件 - 或留空以创建新扩展
- 如果使用不同的
.pem文件会发生这种情况 - 使用原始
.pem文件以保持相同的 ID
当前版本:0.4.5
版本号定义在:
src/manifest.json- 扩展版本src/config-manager.js- 配置版本src/newtab.html- 显示的版本
打包前请确保所有版本号匹配!