saadtazi / firefox-profile-js

Firefox Profile creation using nodejs and CLI
MIT License
60 stars 30 forks source link

Install temporary addon #125

Open fregante opened 3 years ago

fregante commented 3 years ago

Firefox only allows signed addons to be installed permanently so I wonder if there's any way for this module to install addons. The source mentions possible installs from a directory (not just an xpi) but I think it only works for Firefox Developer

https://github.com/saadtazi/firefox-profile-js/blob/08a4e4cefcb5f023ad6f10e9d869c812b59fa9af/lib/firefox_profile.js#L576

https://github.com/saadtazi/firefox-profile-js/blob/08a4e4cefcb5f023ad6f10e9d869c812b59fa9af/README.md#L79

web-ext seems to be installing the extension after opening the browser:

https://github.com/mozilla/web-ext/blob/8bd0d13f425bbaed6cfc2f8127883c5c43010f1d/src/firefox/remote.js#L139-L143

Is there any other way for unsigned/local/unpacked addons?

saadtazi commented 3 years ago

Hi @fregante , It's being a long time I haven't use my package, and I am away from keyboard for a couple of days. What i found by looking at the documentation of firefox-profile-service (https://www.npmjs.com/package/@wdio/firefox-profile-service) which depends on this package: i think you can skip the signature verification:

'xpinstall.signatures.required': false,
legacy: true // only use for firefox <= 55

I hope it helps (... but not tested myself) Please keep me posted!

fregante commented 3 years ago

Unfortunately that hasn't worked for a couple of years since Firefox requires Addons to be signed. The only way I'm aware of is to open Firefox first and then request the installation via WebDriver, which is not ideal.

fregante commented 2 years ago

web-ext manages to install the extension by packing it first:

https://github.com/mozilla/web-ext/blob/416b12895109331170a5b4f3af64e83918f2488b/src/firefox/index.js#L474-L541

whereas extensions added via firefox-profile (under the /extensions/ folder) are just deleted when Firefox loads the profile:

firefox-profile -o ffprofile -e path/to/extension
/Applications/Firefox.app/Contents/MacOS/firefox-bin -profile ffprofile
fregante commented 2 years ago

I'm leaving it open for reference, but this is just not possible anymore. Firefox requires an RDP call to install unsigned extensions, it can't be done via profile.

christian-bromann commented 1 year ago

@fregante I am not facing the same issue and am unable to load any extension. Have you been able to find a workaround?

fregante commented 1 year ago

See my previous comment: it's not possible, use web-ext

christian-bromann commented 1 year ago

For reference, I ended up using WebdriverIO to inject a temporary extension at runtime via:

const extension = await fs.readFile(path.resolve(__dirname, '..', `runme-firefox-v${pkg.version}.xpi`))
await browser.installAddOn(extension.toString('base64'), true)