Skip to content

Instantly share code, notes, and snippets.

@danbeam
Created August 26, 2011 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danbeam/1172951 to your computer and use it in GitHub Desktop.
Save danbeam/1172951 to your computer and use it in GitHub Desktop.
remove Firefox extension maxVersion
#!/bin/bash
usage() {
cat >&2 <<EOT
Usage: $(basename $0) <a_url_to_a_ff_ext.xpi>
EOT
exit 1;
}
if [ "$#" -lt "1" ]; then
usage;
fi
prevdir=$(pwd);
tmpdir=$(mktemp -d -t "$name-XXXX");
clean_up () {
rm -rf "$tmpdir";
}
die_earlier () {
[ ! -z "$1" ] && echo -e "$1" >&2;
clean_up;
exit 1;
}
trap die_earlier HUP INT TRAP;
url="$1";
filename=$(basename "$url");
unmaxed="${filename%.xpi}-unmaxed.xpi";
cd "$tmpdir";
curl -sO "$url";
unzip -q "$filename" -d unzipped || die_earlier "There were problems unzipping your file.\nAre you sure it's a Firefox extension?";
if [ -e unzipped/install.rdf ]; then
echo 1 | sed -re 's/1//' &>/dev/null; # feature detect sed, lol
if [ "$?" -eq "0" ]; then
sed -i -r -e 's/maxVersion>[^>]+</maxVersion>\*</' unzipped/install.rdf;
else
sed -E 's/maxVersion>[^>]+</maxVersion>\*</' unzipped/install.rdf > stupid-os-x.txt;
mv -f stupid-os-x.txt unzipped/install.rdf;
fi
else
die_earlier "Didn't find an install.rdf in that file.\nAre you sure it's a Firefox extension?";
fi
cd unzipped;
zip -q -r "$prevdir/$unmaxed" .;
echo "Drag and drop $prevdir/$unmaxed to Firefox to install";
clean_up;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment