Firefoxy

brockwalters
Contributor II

I am not a huge Firefox user, but, there are so many things that are great about it & about how it's made that I sometimes get sad it isn't as popular as it used to be especially given the fact that Google & Google Chrome (which are destroying the internet...) have no real competition. 

Here is a quick example...

Firefox publishes a URL to get information about updates & releases which returns a simple JSON object:

 

%  curl -LsS https://product-details.mozilla.org/1.0/firefox_versions.json
{
    "FIREFOX_AURORA": "",
    "FIREFOX_DEVEDITION": "101.0b9",
    "FIREFOX_ESR": "91.9.1esr",
    "FIREFOX_ESR_NEXT": "",
    "FIREFOX_NIGHTLY": "102.0a1",
    "FIREFOX_PINEBUILD": "",
    "LAST_MERGE_DATE": "2022-05-02",
    "LAST_RELEASE_DATE": "2022-05-03",
    "LAST_SOFTFREEZE_DATE": "2022-04-28",
    "LATEST_FIREFOX_DEVEL_VERSION": "101.0b9",
    "LATEST_FIREFOX_OLDER_VERSION": "3.6.28",
    "LATEST_FIREFOX_RELEASED_DEVEL_VERSION": "101.0b9",
    "LATEST_FIREFOX_VERSION": "100.0.2",
    "NEXT_MERGE_DATE": "2022-05-30",
    "NEXT_RELEASE_DATE": "2022-05-31",
    "NEXT_SOFTFREEZE_DATE": "2022-05-26"
}

 

So easy & practical. Want the latest Firefox version? Here's one way that does not require anything other than commands available in the shell:

 

% jsonval(){                                                                                  
JSON="$1" osascript -l 'JavaScript' \
	-e 'const env = $.NSProcessInfo.processInfo.environment.objectForKey("JSON").js' \
	-e "JSON.parse(env).$2"
}
% data="$(curl -LsS https://product-details.mozilla.org/1.0/firefox_versions.json)"
% key='LATEST_FIREFOX_VERSION'
% jsonval "$data" "$key"
100.0.2

 

Much of the credit for this code belongs to these posts:

https://paulgalow.com/how-to-work-with-json-api-data-in-macos-shell-scripts

https://www.macblog.org/parse-json-command-line-mac/

with assistance from @pico in the macadmins Slack #scripting & #bash channels.

My absolute favorite thing in the Firefox update data, however, is "NEXT_RELEASE_DATE" !!!!

 

% key='NEXT_RELEASE_DATE'
% jsonval "$data" "$key" 
2022-05-31

 

If only all software publishers were so organized & conscientious...

1 REPLY 1

brockwalters
Contributor II

Here is another reason to like Firefox...

https://wiki.tilde.institute/w/firefox-address-bar-tips