问题描述
我发现了问题如何安装 Firefox 插件从脚本中的命令行? 似乎适用于 Firefox 扩展(即带有 install.rdf 文件的扩展)但是 WebExtensions(带有 manifest.json 的扩展)呢?em> 文件)?
I found the question How to install Firefox addon from command line in scripts? that seems to work for Firefox extensions (i.e. ones with an install.rdf file) but what about WebExtensions (extension with a manifest.json file instead)?
推荐答案
请看:
您在 askubuntu 上链接的问题:如何在脚本中从命令行安装 Firefox 插件? 已经过时几年了,但确实有一些很好的信息.
The question you link on askubuntu: How to install Firefox addon from command line in scripts? is several years out of date, but does have some good information.
此时,大多数 Mozilla 附加组件,包括所有 Firefox WebExtension 附加组件,都是通过将附加组件的 .xpi
文件放置在具有正确名称的适当目录中来手动安装的扩展而不解压(解压)内容.[您也可以通过在 Firefox 中下载它们、将 .xpi
拖放到 Firefox/Thunderbird 等来安装它们]
At this point, most Mozilla add-ons, including all Firefox WebExtension add-ons, are installed manually by placing the add-on's .xpi
file in the appropriate directory with the correct name for the extension without unpacking (unzipping) the contents. [You can also install them by downloading them in Firefox, drag-and-drop the .xpi
onto Firefox/Thunderbird, etc.]
您可以通过解压附加组件的 .xpi
文件并查看 install.rdf
文件,看看它是否有 <em:unpack>true</em:unpack>
.所有的 WebExtensions 都没有这个文件,不用解压就安装了.
You can determine those add-ons that must be unpacked by unpacking the add-on's .xpi
file and looking at the install.rdf
file to see if it has <em:unpack>true</em:unpack>
. All WebExtensions don't have this file and are installed without unpacking.
.xpi
文件必须命名为 [extensionID].xpi
.您可以从 install.rdf
文件(非 WebExtension 附加组件)中找到扩展 ID.在该文件中,您正在查找
The .xpi
file must be called [extensionID].xpi
. You can find the extension ID from either the install.rdf
file (non-WebExtension add-ons). In that file, you are looking for <em:id>ThisEntireStringIsTheAddOnsID</em:id>
对于 WebExtension,ID 位于 文件>applications 属性:
For a WebExtension, the ID is in the
manifest.json
file under the applications property:
"applications": {
"gecko": {
"id": "ThisEntireStringIsTheAddOnsID"
}
},
对于上述两个示例,
.xpi
文件必须重命名为 ThisEntireStringIsTheAddOnsID.xpi
For both of the above examples the
.xpi
file must be renamed to ThisEntireStringIsTheAddOnsID.xpi
如果
install.rdf
文件包含 ,则
.xpi
中的文件code> 必须解压(解压缩)并放置在扩展目录下的子目录中.在上面的 install.rdf
示例中(同样,WebExtensions 未 解包),目录将命名为:ThisEntireStringIsTheAddOnsID
If the
install.rdf
file includes <em:unpack>true</em:unpack>
, then the files in the .xpi
must be unpacked (unzipped) and placed in a subdirectory under the extensions directory. In the above install.rdf
example (again WebExtensions are not unpacked), the directory would be named: ThisEntireStringIsTheAddOnsID
您放置
.xpi
文件或解压目录的扩展目录是(部分信息 从 MDN 复制):
The extension directories where you put the
.xpi
file or unpacked directory are (information partially copied from MDN):
对于运行特定版本 Firefox 的所有用户:
[Firefox 安装目录]/browser/extensions/
For all users running a particular version of Firefox:
[Firefox install directory]/browser/extensions/
当该版本的 Firefox 运行时,Firefox 会要求用户确认安装附加组件.用户将无法删除扩展,只能禁用它.扩展程序不会自动更新.
Firefox will ask the user to confirm installation of the add-on when that version of Firefox is run. The user will not have the ability to remove the extension, only disable it. The extension will not be automatically updated.
对于运行特定版本 Firefox 的所有用户:
[Firefox 安装目录]/distribution/extensions
For all users running a particular version of Firefox:
[Firefox install directory]/distribution/extensions
第一次使用该版本的 Firefox 运行配置文件时,将为所有用户/配置文件安装扩展.扩展程序将被复制到配置文件的
extensions
目录中,用户除了禁用它之外还可以删除它.不会要求用户确认安装.复制到每个配置文件的扩展将与为该配置文件安装的所有其他扩展一起自动更新.您应该不要解压此目录中的任何 .xpi
文件.如果需要解压文件,Firefox 会在每个配置文件中安装扩展程序时自动完成.
The extension will be installed for all users/profiles the first time the profile is run with that version of Firefox. The extension will be copied into the profile's
extensions
directory and the user will be able to remove it in addition to disabling it. The user will not be asked to confirm installation. The extension copied to each profile will be automatically updated along with all other extensions installed for that profile. You should not unpack any .xpi
files in this directory. If the file needs to be unpacked, it will be done automatically by Firefox when the extension is installed in each profile.
对于特定用户的特定个人资料:
[配置文件目录]/extensions/
For a particular User's specific profile:
[profile directory]/extensions/
在 Windows 上:
特定用户的所有个人资料:<I>%appdata%\Mozilla\Extensions\{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</I>
配置文件目录位于:
\Mozilla\Firefox\Profiles\*
Profile directories are located at:
<i>\Mozilla\Firefox\Profiles\*</i>
OSX:
对于所有用户:/Library/Application Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
仅针对特定用户,将其放置在该用户的库文件夹层次结构中:
~/Library/Application Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
Just for a specific user, place it in that user's library folder hierarchy:
~/Library/Application Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
Linux:
对于所有用户:/usr/lib/Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
或
/usr/lib64/Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
或
/usr/share/Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
仅针对特定用户:
~/.Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
您链接的问题/答案中提到的
-install-global-extension
选项是 从 Gecko 1.9.2 起从 Firefox 中删除(很久以前).
The
-install-global-extension
option mentioned in the question/answer you linked was removed from Firefox as of Gecko 1.9.2 ( a long time ago).
这篇关于从命令行在 Firefox 上安装 WebExtensions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!