In rare cases, sometimes you'll want to add some code into your experiment for QA purposes. A perfect example would be to add simple console.log statements throughout the code to perhaps see if certain code is being executed during startup, or if it's being executed at all.
Editing XPI Files
- Rename the XPI file to a ZIP file using the following command:
- mv experiment.xpi experiment.zip
- Unzip exerpiment.zip using the following command:
- unzip -d <destination folder> <filename>.zip (Example: unzip -d experiment experiment.zip)
Once you've unzipped the files from experiment.zip, you can then make the desired changes.
NOTE: WHEN YOU'RE RE-ZIPPING THE DIRECTORY, IT NEEDS TO USE THE SAME DIRECTORY STRUCTURE AS THE ORIGINAL XPI FILE OR YOU'LL RUN INTO ISSUES
- Once you've completed the needed changes, you can re-zip everything using the following command:
- zip -r <filename>.zip <destination of files> (Example: zip -r experiment.zip *)
- Rename the newly created zip file back to a XPI file using the same command we used before:
- mv experiment.zip experiment.xpi
Changing Manifest SHA256 Hash
Once you've finished creating the new XPI file above, we'll need to update firefox-manifest.json to use the new experiment.xpi SHA256 hash as we've changed the original file.
You can retrieve a files hash using the shasum utility. In this case, will need to retrieve the SHA256 hash using the following command:
- shasum -a 256 <filename> (Example: shasum -a 256 experiment.xpi)
- Example Output: 99ec788a5da354c9d046548e9733dbbff407b6f5f6a86fffc71410463ee64e35 experiment.xpi
Once you have the new hash, you'll need to replace the older one under "xpiHash": in firefox-manifest.json.
If you don't add the new hash and you've changed the files inside the XPI, you'll receive errors in the browser console when attempting to install the experiment.