aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/mozilla/add-ons/webextensions/manifest.json/browser_specific_settings/index.html
blob: 1aa1d4d492140a5028bacfb1d06e8c2936a3b1aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
title: applications
slug: Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings
tags:
  - 擴充套件
translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings
---
<div>
<div>{{AddonSidebar}}</div>

<table class="fullwidth-table standard-table">
 <tbody>
  <tr>
   <th scope="row" style="width: 30%;">型別</th>
   <td><code>Object</code></td>
  </tr>
  <tr>
   <th scope="row">強制</th>
   <td>通常是不強制(請看<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/WebExtensions_and_the_Add-on_ID#When_do_you_need_an_add-on_ID">你什麼時候會需要 Add-on ID?</a>)。在 Firefox 48(桌面)前以及Android版Firefox 是強制的。</td>
  </tr>
  <tr>
   <th scope="row">範例</th>
   <td>
    <pre class="brush: json no-line-numbers  language-json">
<code class="language-json"><span class="key token">"applications":</span> <span class="punctuation token">{</span>
  <span class="key token">"gecko":</span> <span class="punctuation token">{</span>
    <span class="key token">"id":</span> <span class="string token">"addon@example.com"</span><span class="punctuation token">,</span>
    <span class="key token">"strict_min_version":</span> <span class="string token">"42.0"</span>
  <span class="punctuation token">}</span>
<span class="punctuation token">}</span></code></pre>
   </td>
  </tr>
 </tbody>
</table>

<h2 id="敘述">敘述</h2>

<p><code>applications</code> 鍵包含了詳細描述特定應用的鍵。</p>

<p>目前這只包含了一個鍵,<code>gecko</code>,它包含4個string參數:</p>

<ul>
 <li><code>id</code> 是套件ID。Firefox 48 以後爲選擇性,48前爲強制。需要什麼來指定 add-on ID 請查看<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/WebExtensions_and_the_Add-on_ID">套件與 Add-on ID</a></li>
 <li><code>strict_min_version</code>:支持的最舊Gecko版本。在這個欄位版本號包含 "*" 是不合法的。預設是 "42a1"。</li>
 <li><code>strict_max_version</code>: 支持的最新Gecko版本。如果套件安裝的 Firefox 版本超過這個版本號則套件會被禁用或不被允許安裝。預設爲 "*",表示禁用最新支持版本檢查。</li>
 <li><code>update_url</code><a href="https://developer.mozilla.org/en-US/Add-ons/Updates">套件更新 manifest</a>。備:連結必須以 "https" 開頭。這個鍵用來自己管理套件更新(不透過套件管理器)。</li>
</ul>

<p>查看<a href="https://addons.mozilla.org/en-US/firefox/pages/appversions/">可用Gecko版本</a></p>

<h3 class="highlight-spanned" id="套件ID格式"><span class="highlight-span">套件ID格式</span></h3>

<p>套件ID格式必須是下列其中一種:</p>

<ul>
 <li><a href="https://en.wikipedia.org/wiki/Universally_unique_identifier" title="Generating_GUIDs">GUID</a></li>
 <li>寫得像信箱地址的字串:<code class="plain">extensionname@example.org</code></li>
</ul>

<p>後者比較容易產生與操作。小心,在這裡使用真實信箱地址可能會引來垃圾信件。</p>

<p>例如:</p>

<pre class="brush:json;auto-links:false no-line-numbers  language-json"><code class="language-json"><span class="key token">"id":</span> <span class="string token">"extensionname@example.org"</span><span class="punctuation token">,</span>

<span class="key token">"id":</span> <span class="string token">"{daf44bf7-a45e-4450-979c-91cf07434c3d}"</span></code></pre>

<p> </p>

<h2 id="範例">範例</h2>

<p>包含所有可用鍵的範例。註:大多數套件會忽略 <code>strict_max_version</code><code>update_url</code></p>

<pre class="brush: json no-line-numbers  language-json"><code class="language-json"><span class="key token">"applications":</span> <span class="punctuation token">{</span>
  <span class="key token">"gecko":</span> <span class="punctuation token">{</span>
    <span class="key token">"id":</span> <span class="string token">"addon@example.com"</span><span class="punctuation token">,</span>
    <span class="key token">"strict_min_version":</span> <span class="string token">"42.0"</span><span class="punctuation token">,</span>
    <span class="key token">"strict_max_version":</span> <span class="string token">"50.*"</span><span class="punctuation token">,</span>
    <span class="key token">"update_url":</span> <span class="string token">"https://example.com/updates.json"</span>
  <span class="punctuation token">}</span>
<span class="punctuation token">}</span></code></pre>

<h2 id="瀏覽器兼容">瀏覽器兼容</h2>
</div>

<p>{{Compat("webextensions.manifest.browser_specific_settings")}}</p>