Determine extension ID

来自WordPress中文文档
跳转至: 导航搜索

Each extension has a unique extension ID which is contained in the extension's install.rdf file. When you want to determine an extension ID (e.g. to install an extension globally), you can do so by unzipping the extension .xpi and then manually inspecting its install.rdf or you can use one of the following, scripted approaches.

Linux/Unix platforms

This approach requires "unzip" and "xmlstarlet" to be installed on your system. Copy and paste the following bash function in your shell (or integrate it into one of your scripts).

# Retrieve the extension id for an addon from its install.rdf
get_extension_id() {
  unzip -qc $1 install.rdf | xmlstarlet sel \
    -N rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# \
    -N em=http://www.mozilla.org/2004/em-rdf# \
    -t -v \
    "//rdf:Description[@about='urn:mozilla:install-manifest']/em:id"
}

Then determine an extension's ID (Greasemonkey extension taken as an example).

$ get_extension_id greasemonkey-0.8.20100408.6-fx.xpi
{e4a8a97b-f2ed-450b-b12d-ee082ba24781}
$