简体   繁体   English

Firefox附加ID约定

[英]Firefox Add-On ID Conventions

I'm writing a Firefox Add-On using the WebExtension API. 我正在使用WebExtension API编写Firefox插件。 Some of the APIs (such as browser.storage.sync ) require an Add-On ID to be explicitly declared in the add-on's manifest.json file. 某些API(例如browser.storage.sync )要求在附件的manifest.json文件中显式声明一个附件ID

The documentation for IDs states: ID文档指出:

The ID of the extension, which must be one of the following: 扩展名的ID,必须为以下之一:

  • GUID (Firefox 1.0) GUID(Firefox 1.0)
  • A string formatted like so: extensionname@example.org 格式如下的字符串:extensionname@example.org

The latter format is significantly easier to generate and manipulate. 后一种格式明显更易于生成和操作。 Firefox 1.5 has checking to ensure that your id falls into one format or the other and will refuse to install add-ons that have malformed ids. Firefox 1.5会进行检查以确保您的ID属于一种格式或另一种格式,并且会拒绝安装ID格式错误的加载项。 You should not use a real email address for your id, however, as it might attract spam. 但是,您不应使用真实的电子邮件地址作为ID,因为它可能会吸引垃圾邮件。

The documentation is not very clear with regards to what kind of string I can provide. 关于我可以提供哪种字符串,文档不是很清楚。 Is it... 是吗...

  • Any valid email address? 任何有效的电子邮件地址?
  • Any string that "looks like" something@something.something? 任何“看起来像” something@something.something的字符串?
  • How about a@bcdefg? a @ bcdefg呢?
  • Should it be relevant to the extension itself? 它应该与扩展本身有关吗?
  • Should it have a domain name I own or can it be any? 它应该是我拥有的域名还是可以是任何域名?

etc. 等等

Because I must declare the ID explicitly to use browser.storage.sync , I am unable to depend on the automatic ID that can be provided by Firefox for WebExtensions. 因为我必须明确声明ID才能使用browser.storage.sync ,所以我无法依赖Firefox可以为WebExtensions提供的自动ID

What are the conventions for explicitly declared add-on IDs in Firefox? Firefox中明确声明的附加ID有哪些约定?

The actual requirement is that the ID matches the following RegExp : 实际要求是该ID与以下RegExp相匹配

var gIDTest = /^(\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}|[a-z0-9-\._]*\@[a-z0-9-\._]+)$/i

The use of a GUID or something approximating an email address is a requirement which is clearly stated in the MDN documentation on Install Manifests (used in legacy add-ons). 在安装清单MDN文档 (用于旧式附件)中明确说明了使用GUID或近似电子邮件地址的要求。 That it is one or the other is enforced by a check which was placed in the Firefox code as of Firefox 1.5. 从Firefox 1.5开始,通过在Firefox代码中放置的检查来强制执行一个或另一个检查。 The above RegExp can be described as: 上面的RegExp可描述为:

  1. Must be a GUID using hexadecimal digits in the format {8digits-4digits-4digits-4digits-12digits} or 必须是格式为{8digits-4digits-4digits-4digits-12digits}十六进制GUID
  2. A string containing a single @ with at least 1 character after the @ . 含有单个字符串@与后至少1个字符@
    1. All characters in the @ format must match /[a-z0-9-\\._]/i (other than the single @ ). @格式的所有字符都必须与/[a-z0-9-\\._]/i匹配(单个@除外)。
    2. The @ format can have zero or more characters prior to the @ @格式可以在@之前包含零个或多个字符。
    3. The @ format does not need to be a valid email address. @格式不必是有效的电子邮件地址。 It doesn't have to have a valid domain. 它不必具有有效的域。 It doesn't even need to be something which could be a valid email address. 它甚至不必是可以是有效电子邮件地址的内容。 It just has to match the RegExp. 它只需要匹配RegExp。

It's recommended that if you are selecting an ID, that you use the @ format, not a GUID . 建议您选择ID时,请使用@格式,而不要使用GUID

For the @ format, it's generally used as [some ID/name for extension]@[something representing the developer] . 对于@格式,通常用作[some ID/name for extension]@[something representing the developer] While the part before and after the @ tend to have a format that looks like it could be username@domain, I've seen add-on IDs where the "username" is blank and/or the "domain" is a single word. 虽然@前后的部分倾向于采用看起来像username @ domain的格式,但我看到了附加ID,其中“用户名”为空白和/或“域”为单个单词。 For example, @a would be a valid ID. 例如, @a将是有效的ID。

The ID must be unique 该ID必须是唯一的

In addition to the format requirements, there is the requirement that: 除了格式要求外,还要求:

  • The ID must be unique across all add-ons that have been submitted to Mozilla (by anyone, ever). 在已提交给Mozilla的所有加载项(任何人曾经有过)中,该ID必须唯一。

As to it being unique among all add-ons submitted to Mozilla: You'll find out if it's unique when you first attempt to submit it to Mozilla for signing. 关于它在提交给Mozilla的所有附加组件中都是唯一的:当您首次尝试将其提交给Mozilla进行签名时,您会发现它是否唯一。 If it does already exist, you will have to change it in order to successfully submit your add-on. 如果已经存在,则必须对其进行更改才能成功提交您的加载项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM