aboutsummaryrefslogtreecommitdiff
path: root/files/ja/mozilla/add-ons/webextensions/manifest.json/background/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/mozilla/add-ons/webextensions/manifest.json/background/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/mozilla/add-ons/webextensions/manifest.json/background/index.html')
-rw-r--r--files/ja/mozilla/add-ons/webextensions/manifest.json/background/index.html115
1 files changed, 115 insertions, 0 deletions
diff --git a/files/ja/mozilla/add-ons/webextensions/manifest.json/background/index.html b/files/ja/mozilla/add-ons/webextensions/manifest.json/background/index.html
new file mode 100644
index 0000000000..96eca3f2fb
--- /dev/null
+++ b/files/ja/mozilla/add-ons/webextensions/manifest.json/background/index.html
@@ -0,0 +1,115 @@
+---
+title: background
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/background
+tags:
+ - Add-ons
+ - Extensions
+ - Manifest
+ - Reference
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/background
+---
+<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>いいえ</td>
+ </tr>
+ <tr>
+ <th scope="row">例</th>
+ <td>
+ <pre class="brush: json no-line-numbers">
+"background": {
+ "scripts": ["background.js"]
+}</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p><code>background</code> を使って拡張機能に 1 つ以上のバックグラウンドスクリプトや、オプションとしてバックグラウンドページを含めます。</p>
+
+<p>バックグラウンドスクリプトは、特定のウェブページやブラウザーウィンドウとは独立した、長い期間の状態や、長い期間の操作を維持する必要があるコードを置く場所です。</p>
+
+<p><code>persistent</code> が <code>false</code> と指定されている場合を除き、バックグラウンドスクリプトは拡張機能が読み込まれるとすぐに読み込まれて、拡張機能が無効化やアンインストールされるまで読み込まれたままになります。スクリプト内では、必要な <a href="/ja/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permissions</a> を要求している限り、あらゆる WebExtension APIs を使用できます</p>
+
+<p>詳しくは <a href="/ja/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_pages">拡張機能の中身</a>の「バックグラウンドページ」の節を見てください。</p>
+
+<p><code>background</code> キーは次の 2 つのプロパティ(両方ともオプションです)のうち 1 つを持つオブジェクトです:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>"scripts"</code></td>
+ <td>
+ <p>文字列配列であり、各要素は JavaScript ファイルへのパスです。パスは manifest.json を基準にした相対パスです。これらは、拡張機能に含まれるバックグラウンドスクリプトです。</p>
+
+ <p>これらのスクリプトは、同じグローバル <code>window</code> を共有します。</p>
+
+ <p>これらのスクリプトは、配列内の出現順で読み込まれます。</p>
+
+ <p><code>"scripts"</code> を指定したときは、スクリプトを実行するための空のバックグラウンドページが作られます。</p>
+
+ <div class="note">
+ <p><strong>注:</strong> <code>&lt;script&gt;</code> タグを使って外部からスクリプトを取り込む場合 (例: <code>&lt;script src = "https://code.jquery.com/jquery-1.7.1.min.js"&gt;</code>)、拡張機能の manifest.json で <code><a href="/ja/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_security_policy">content_security_policy</a></code> キーを変更する必要があります。</p>
+ </div>
+
+ <div class="note">
+ <p><strong>注:</strong> Firefox 50 より前のバージョンにはこれに影響するバグがあることに注意してください。Firefox のデバッガーが開いているときは、必ずしも配列内の出現順でスクリプトが読み込まれるとは限りません。このバグに対処するには、<code>"page"</code> プロパティを使い、そのページから <code>&lt;script&gt;</code> タグによってバックグラウンドスクリプトを読み込んでください。このバグは Firefox 50 で修正され、それ以降は常に配列内の出現順でスクリプトが読み込まれます。</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>"page"</code></td>
+ <td>
+ <p>もしバックグラウンド ページに何か内容を持たせたい場合、そのページを <code>"page"</code> により指定することができます。 manifest.json から拡張機能の中に含まれるHTMLドキュメントを参照するためのパス文字列の <code>String</code> を指定します。</p>
+
+ <p>このプロパティを使うときは、<code>"scripts"</code> を使ってバックグラウンドスクリプトを指定することはできませんが、通常のウェブページと同じように、バックグラウンドページ内からスクリプトを読み込むことができます。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p><code>background</code> は以下の追加のキーを含むこともできます:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>persistent</code></td>
+ <td>
+ <p><code>Boolean</code> の値。</p>
+
+ <ul>
+ <li><code>true</code> を指定すると、拡張機能が読み込まれるかブラウザーが起動した時から、拡張機能の削除、無効化、もしくはブラウザーが終了するまでの間、バックグラウンドページがメモリー上に保持され続けます(つまり、バックグラウンドページが永続化されます)。</li>
+ <li><code>false</code> を指定すると、バックグラウンドページはアイドル状態の時にメモリー上からアンロードされ、必要に応じて再生成されます。このようなバックグラウンドページは、リスナーを登録したイベントを処理するためだけにメモリー上に読み込まれるため、イベントページとも呼ばれます。バックグラウンドページがメモリ上からアンロードされていても、リスナーの登録状態は永続化されますが、他の値は永続化されません。イベントページにおいてデータを永続化したい場合は、<a href="https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage">storage API</a>を使う必要があります。</li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Example" name="Example">例</h2>
+
+<pre class="brush: json no-line-numbers">  "background": {
+    "scripts": ["jquery.js", "my-background.js"]
+  }</pre>
+
+<p>2つのバックグラウンドスクリプトを読み込みます。</p>
+
+<pre class="brush: json"> "background": {
+ "page": "my-background.html"
+ }</pre>
+
+<p>カスタムのバックグラウンドページを読み込みます。</p>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザ実装状況</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.background", 10)}}</p>