How to programmatically activate extensions with no ID?

User Help for Mozilla Firefox
Locked
mozvicque
New Member
Posts: 1
Joined: November 29th, 2022, 10:15 am

How to programmatically activate extensions with no ID?

Post by mozvicque »

I'm trying to get extension IDs from the manifest.json file shipped with respective extension XPI using a bash script. I use the extracted ID data to rename XPIs and to copy them to folder .mozilla/firefox/<profile_name>/extensions. However, some of these XPIs have no ID, as specified here, which means that Firefox won't recognise (automatically activate) them when launched.

I know that the ID field is not mandatory under manifest v2, and Firefox generates a unique GUID for each XPI with no ID when one's downloaded directly from the Addons Store or installed manually.

For testing, I created a new profile, installed the downloaded XPI manually and checked the created GUID - it matches the one installed on a different profile. So, I assume the GUID generation algorithm is stably based on a certain parameter of the XPI in question, e.g. file's hash value or size, I don't know.
  • That said, can I generate GUIDs for non-IDed extensions programmatically with tools like e.g. uuidgen (Linux)? Is it a viable option at all?
  • If not, what's the recommended way of installing such XPIs with a bash script (without user interaction and manual install)?
Thank you!

Victor
User avatar
DanRaisch
Moderator
Posts: 127187
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Re: How to programmatically activate extensions with no ID?

Post by DanRaisch »

Moving to Firefox Support.
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Re: How to programmatically activate extensions with no ID?

Post by dickvl »

Those extensions may still have an ID stored in mozilla.rsa in the META-INF folder, so maybe check that file.
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: How to programmatically activate extensions with no ID?

Post by morat »

I parsed uBlock Origin extension id using certutil on Windows.

uBlock Origin extension id: uBlock0@raymondhill.net

certutil.exe -dump mozilla.rsa

Extract extension id from mozilla.rsa (see Linux command)
http://stackoverflow.com/questions/54089986
User avatar
therube
Posts: 21703
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: How to programmatically activate extensions with no ID?

Post by therube »

Oh, so it's the "CN=" that you need to look for?

Perhaps naming convention is a free-for-all?

Likewise, multiple CN records are in the .rsa file.
Perhaps it is the final one?
(I have no clue about such things.)

Code: Select all

C:\>certutil.exe -dump mozilla-noscript.rsa | grep CN= | tail -1
    CN={73a6fe31-595d-460b-a920-fcc0f8843232}

C:\>certutil.exe -dump mozilla.ublock.rsa | grep CN= | tail -1
    CN=uBlock0@raymondhill.net
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: How to programmatically activate extensions with no ID?

Post by morat »

The doc says the subject common name (CN) must match the extension id.

More info
http://wiki.mozilla.org/Add-ons/Extension_Signing

Code: Select all

certutil.exe -dump mozilla.rsa | for /f "skip=2 delims==, tokens=2" %a in ('find "Subject: CN="') do @echo extension id: %a
Locked