What is the command line to show the list of all installed extensions on the firefox browser? Is there any. I checked man firefox
but did not help.
4 Answers
Give a try to this grep
oneliner command to list all the firefox addons,
grep -oP '(?<=\},\"name\":\")([^"]*)' ~/.mozilla/firefox/*.default/addons.json
OR
This worked for me:
user@host:~$ cat ~/.mozilla/firefox/*.default/addons.json |
python -c 'import json,sys;obj=json.load(sys.stdin);
for (i, x) in enumerate(obj["addons"]):
print x["name"]' | uniq
Output in my case:
Clean Links
Tee-Timer
Explanation:
cat ~/.mozilla/firefox/*.default/addons.json
: reads the addons.json file in each profile.python -c 'import json,sys;obj=json.load(sys.stdin);
load the json parser library of python and loads json via stdin (standard input), ergo fromcat
for (i, x) in enumerate(obj["addons"]):
phyton code to loop through the array of addons...print x["name"]' | uniq
...and print its name only one.
-
-
-
1This is very good (+1) but needlessly complex. You don't need to escape the
"
in your regex and you also don't really need the lookbehind. There is no guarantee that the home dir will be/home/$(whoami)
it could be anywhere. A better approach would be to use~/
or$HOME
. There's no point in finding the default profile name either. It will always end in.default
and even if there are more, you can parse all of them and pass throughuniq
. TheUSER=user
is pointless, there is already a global variable calledUSER
that holds your username.– terdonJun 20, 2014 at 9:40 -
-
The Python version choked on an extension with an accented character. But the grep version, and also terdon's shorter grep version both work fine.– mivkJan 12, 2017 at 0:08
This is basically just a simplified version of @chaos's approach:
grep -oP '},"name":"\K[^"]*' ~/.mozilla/firefox/*.default/addons.json
There's no reason to get the name of the user, you can always just use ~/
or $HOME
to get the home directory. The name of the default profile is, likewise, unneeded. You probably only have one and its name will be RandomString.default
. If you have more than one, and different addons for each, this approach will list all of them. So, if you do have multiple profiles, you might want to add | uniq
to the above command to remove duplicates.
Explanation
grep -oP
: the-o
causesgrep
to only print the matched portion of the line and the-P
activates Perl Compatible Regular Expressions which are needed for the\K
(see below).},"name":"\K[^"]*
: match the longest stretch of non-"
characters ([^"]*
) that come right after},"name":
. The\K
means "ignore everything matched up to here" which, when combined with-o
, will cause only the part of the match after thename:":"
to be printed.~/
: this is your home directory.
Following scriptlet is just a more-featureful version of @chaos's code. My motivations were
- I use more than one Firefox profile.
- I put my Firefox profiles in a different dir/folder than the default: see
FIREFOX_PROFILE_ROOT
in script/let, which you should probably edit (back to the default), or use the newerprofiles.ini
-parsing code (see link below). - I wanted to see more information about my add-ons, since I was having a problem that turned out to be extension-version-related.
- I just hadn't coded for a few days
:-)
You can also {see the latest version of this code, use the latest version as a downloadable script file} here. Note the newer code also parses profiles.ini
(using the profile paths you define there) rather than relying (as below) on you telling the code where to find your profiles.
### List add-ons in all local Firefox profiles. Requires:
### * users to know where they keep their Firefox profiles. TODO: parse `profiles.ini`
### * python (to parse the add-ons JSON)
### Tested on Linux with Python versions={2.7.9, 3.4.2}.
### Copyright (C) 2017 Tom Roche <[email protected]>
### This work is licensed under the Creative Commons Attribution 4.0 International License.
### To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/
#FIREFOX_PROFILE_ROOT="${HOME}/.mozilla/firefox" # default Firefox path, which ...
FIREFOX_PROFILE_ROOT="${HOME}/firefox" # ... I override, but you probably should not!
FIREFOX_ADDONS_FILENAME='addons.json' # default Firefox value
FIREFOX_ADDONS_FP_LIST='' # default empty
### find add-ons JSON files:
if [[ ! -r "${FIREFOX_PROFILE_ROOT}" ]] ; then
>&2 echo "ERROR: cannot read FIREFOX_PROFILE_ROOT='${FIREFOX_PROFILE_ROOT}', exiting ..."
else
FIREFOX_ADDONS_FP_LIST="$(find "${FIREFOX_PROFILE_ROOT}/" -type f -name "${FIREFOX_ADDONS_FILENAME}" | fgrep -ve 'blocklists')"
# echo -e "FIREFOX_ADDONS_FP_LIST=\n${FIREFOX_ADDONS_FP_LIST}" # debugging
if [[ ( -z "${FIREFOX_ADDONS_FP_LIST}" ) ||
( "$(echo ${FIREFOX_ADDONS_FP_LIST} | wc -l)" == '0' ) ]] ; then
>&2 echo "ERROR: found no add-ons files in Firefox profiles under '${FIREFOX_PROFILE_ROOT}', exiting ..."
else
for FIREFOX_ADDONS_FP in ${FIREFOX_ADDONS_FP_LIST} ; do
echo "${FIREFOX_ADDONS_FP} contains:"
### Parse add-ons file using python, so
### * gotta export the envvar
export FIREFOX_ADDONS_FP
### * indenting becomes important
python -c '
import json, os
with open(os.environ.get("FIREFOX_ADDONS_FP")) as addons_file:
addons_data = json.load(addons_file)
for (i, addon) in enumerate(addons_data["addons"]):
print("add-on name=" + addon["name"])
print(" version=" + addon["version"])
print(" URI=" + addon["learnmoreURL"])
print("") # newline
'
echo # newline
done
fi
fi
-
please don't leave comments advertising your (fine) answer on other answers. Your answer is just as visible and you're just spamming the other answerers.– terdonAug 31, 2017 at 17:05
jq
is the simpler way to process JSON data.
jq
is a lightweight and flexible command-line JSON processor.
jq -j '.addons [] | ( .type, ",", .defaultLocale.name, ",", .active, "\n" )' ~/.mozilla/firefox/*.default-*/extensions.json | sort -u
addons.json
doesn't contain 'active' flag (if it's enabled/disabled).
They are also listed on about:support
.
I still want to filter more, just active extensions names and their sourceURI without search.mozilla.org ones (as probably OP wants).