diff options
Diffstat (limited to 'files/ja/mozilla/add-ons/webextensions/api/tabs')
12 files changed, 1492 insertions, 0 deletions
diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/capturevisibletab/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/capturevisibletab/index.html new file mode 100644 index 0000000000..65a036c403 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/capturevisibletab/index.html @@ -0,0 +1,105 @@ +--- +title: tabs.captureVisibleTab() +slug: Mozilla/Add-ons/WebExtensions/API/tabs/captureVisibleTab +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - captureVisibleTab + - tabs +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/captureVisibleTab +--- +<div>{{AddonSidebar()}}</div> + +<p>指定ウィンドウの選択タブの表示領域の画像をエンコードしたデータ URI を作成します。このメソッドを使うには <code><all_urls></code> <a href="/ja/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">パーミッション</a> が必要です (Chrome の場合、<code>activeTab</code> <a href="/ja/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">パーミッション</a> があり、ユーザーが許可の操作を行えば、このメソッドを使うことができます)。</p> + +<p>これは、<code><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> を返す非同期関数です。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox brush:js">var capturing = browser.tabs.captureVisibleTab( + windowId, // optional integer + options // optional extensionTypes.ImageDetails +) +</pre> + +<h3 id="Parameters" name="Parameters">引数</h3> + +<dl> + <dt><code>windowId</code>{{optional_inline}}</dt> + <dd><code>integer</code> 型。対象となるウィンドウ。デフォルトは現在のウィンドウ。</dd> + <dt><code>options</code>{{optional_inline}}</dt> + <dd>{{WebExtAPIRef('extensionTypes.ImageDetails')}} 型。</dd> +</dl> + +<h3 id="Return_value" name="Return_value">戻り値</h3> + +<p><code><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> であり、キャプチャーされたタブの表示領域の画像をエンコードしたデータ URL で fulfilled 状態にされる。このデータ URL は、HTML イメージ要素の 'src' 属性に設定することで、画像を表示できる。もし何らかのエラーが発生した場合、Promise はエラーメッセージによって rejected 状態にされる。</p> + +<h2 id="Examples" name="Examples">使用例</h2> + +<p>現在のウィンドウの選択されたタブの画像を、デフォルト設定でキャプチャーする。</p> + +<pre class="brush: js">function onCaptured(imageUri) { + console.log(imageUri); +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +browser.browserAction.onClicked.addListener(function() { + var capturing = browser.tabs.captureVisibleTab(); + capturing.then(onCaptured, onError); +}); +</pre> + +<p>{{WebExtExamples}}</p> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザー実装状況</h2> + + + +<p>{{Compat("webextensions.api.tabs.captureVisibleTab")}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/tabs#method-captureVisibleTab"><code>chrome.tabs</code></a> API に基づいています。このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> における Chromium のコードに基づいています。</p> + +<p>Microsoft Edge での実装状況は Microsoft Corporation から提供されたものであり、ここでは Creative Commons Attribution 3.0 United States License に従っています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/create/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/create/index.html new file mode 100644 index 0000000000..247bc50464 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/create/index.html @@ -0,0 +1,131 @@ +--- +title: tabs.create() +slug: Mozilla/Add-ons/WebExtensions/API/tabs/create +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/create +--- +<div>{{AddonSidebar()}}</div> + +<p>新しいタブを作ります。</p> + +<p>これは<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>を返す非同期関数です.</p> + +<h2 id="構文">構文</h2> + +<pre class="syntaxbox brush:js">var creating = browser.tabs.create( + createProperties // object +) +</pre> + +<h3 id="パラメータ">パラメータ</h3> + +<dl> + <dt><code>createProperties</code></dt> + <dd>新しいタブについてのプロパティを与える<code>オブジェクト</code>。これらのプロパティについて詳しくは{{WebExtAPIRef("tabs.Tab")}}を参照してください。</dd> + <dd> + <dl class="reference-values"> + <dt><code>active</code>{{optional_inline}}</dt> + <dd>タブをアクティブにするかどうかを<code>真理値</code>で指定します。ウィンドウがフォーカスされているかには影響されません({{WebExtAPIRef('windows.update')}}も参照)。デフォルト値は<code>true</code>.</dd> + <dt><code>cookieStoreId</code> {{optional_inline}}</dt> + <dd><code>文字列</code> 。タブのcookie store IDが<code>cookieStoreId</code>のタブを作るときに使用します。このオプションは拡張機能が<code>"cookies"</code> <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>を持つときのみ使用できます。</dd> + <dt><code>index</code>{{optional_inline}}</dt> + <dd><code>整数値</code>。ウィンドウ中のタブの位置を指定します。数値はゼロからウィンドウ内のタブの数までです。</dd> + <dt><code>openerTabId</code>{{optional_inline}}</dt> + <dd><code>整数値</code>。開くタブのIDを指定します。指定した場合、開く側のタブは新しいタブと同じウィンドウにある必要があります。</dd> + <dt><code>openInReaderMode</code>{{optional_inline}}</dt> + <dd><code>真理値</code>。もし<code>true</code>であれば<a href="/en-US/Add-ons/WebExtensions/API/tabs/toggleReaderMode">リーダーモード</a>で開かれます。 デフォルトは<code>false</code>。</dd> + <dt><code>pinned</code>{{optional_inline}}</dt> + <dd><code>真理値</code>。タブをピン留めするかを指定します。デフォルトは<code>false</code>。</dd> + <dt><code>selected</code>{{optional_inline}}</dt> + <dd><code>真理値</code>。ウィンドウ内で選択されるかどうかを指定します。デフォルトは<code>true</code>。 + <div class="warning">このプロパティは非推奨です。Firefoxではサポートされません。代わりに<code>active</code>を使用してください。</div> + </dd> + <dt><code>url</code>{{optional_inline}}</dt> + <dd><code>文字列</code>。はじめに開くURLを指定します。デフォルトは新しいタブ。</dd> + <dd>スキームを含む完全なURLを指定します。(例えば 'www.google.com' → 'http://www.google.com').</dd> + <dd>セキュリティの観点からFirefoxでは特権URLは使用できません。</dd> + <dd> + <ul> + <li>chrome: URL</li> + <li>javascript: URL</li> + <li>data: URL</li> + <li>file: URL(ファイルシステム上のファイルなど。拡張機能内にパッケージ化されたファイルは指定できます。下部を参照してください)</li> + <li>特権 about: URL (例、 <code>about:config</code>, <code>about:addons</code>, <code>about:debugging</code>)<span style="display: none;"> </span>。ただし非特権 URL (<code>about:blank</code>) は使用できます。</li> + <li>新しいタブ (<code>about:newtab</code>) はURLを指定しなければ開かれます。</li> + </ul> + + <p>拡張機能内のファイルをロードするためにはmanifest.jsonファイルからの絶対パスで指定します。(例: '/path/to/my-page.html')。もし'/'を省略すると相対パスとして解釈されます。またブラウザによっては、また異なった絶対パスとして解釈されます。</p> + </dd> + <dt><code>windowId</code>{{optional_inline}}</dt> + <dd><code>整数値</code>。新しくタブを作るウィンドウを指定します。デフォルトは現在開いているウィンドウ。</dd> + </dl> + </dd> +</dl> + +<h3 id="返り値">返り値</h3> + +<p>新しく作ったタブに関する{{WebExtAPIRef('tabs.Tab')}}オブジェクトを引数に持つ<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>が返されます。URLが特権URLであるなどして、タブが作られなかった場合はpromiseはエラーメッセージとともにrejectされます。</p> + +<h2 id="ブラウザー互換状況">ブラウザー互換状況</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.api.tabs.create", 10)}}</p> + +<h2 id="例">例</h2> + +<p>"https://example.org" を新しいタブで開きます</p> + +<pre class="brush: js">function onCreated(tab) { + console.log(`Created new tab: ${tab.id}`) +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +browser.browserAction.onClicked.addListener(function() { + var creating = browser.tabs.create({ + url:"https://example.org" + }); + creating.then(onCreated, onError); +});</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>このAPIはChromiumの<a href="https://developer.chrome.com/extensions/tabs#method-create"><code>chrome.tabs</code></a> APIに基づいています。 このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> における Chromium のコードに基づいています。</p> + +<p>Microsoft Edge での実装状況は Microsoft Corporation から提供されたものであり、ここでは Creative Commons Attribution 3.0 United States License に従っています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/duplicate/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/duplicate/index.html new file mode 100644 index 0000000000..af56c60bce --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/duplicate/index.html @@ -0,0 +1,98 @@ +--- +title: tabs.duplicate() +slug: Mozilla/Add-ons/WebExtensions/API/tabs/duplicate +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/duplicate +--- +<div>{{AddonSidebar()}}</div> + +<p>ID で指定されたタブを複製します。</p> + +<p>この関数は <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> を返す非同期関数です。</p> + +<h2 id="構文">構文</h2> + +<pre class="syntaxbox brush:js">var duplicating = browser.tabs.duplicate( + tabId // integer +) +</pre> + +<h3 id="パラメータ">パラメータ</h3> + +<dl> + <dt><code>tabId</code></dt> + <dd><code>integer</code>. 複製するタブのIDを指定します。</dd> +</dl> + +<h3 id="戻り値">戻り値</h3> + +<p>A <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that will be fulfilled with a {{WebExtAPIRef('tabs.Tab')}} object containing details about the duplicated tab. The <code>Tab</code> object only contains <code>url</code>, <code>title</code> and <code>favIconUrl</code> if the extension has the <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions"><code>"tabs"</code> permission</a>. If any error occurs the promise will be rejected with an error message.</p> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</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.api.tabs.duplicate")}}</p> + +<h2 id="例">例</h2> + +<p>1つ目のタブを複製し、新しく作られたタブのIDをログに残す例:</p> + +<pre class="brush: js">function onDuplicated(tabInfo) { + console.log(tabInfo.id); +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +// Duplicate the first tab in the array +function duplicateFirstTab(tabs) {console.log(tabs); + if (tabs.length > 0) { + var duplicating = browser.tabs.duplicate(tabs[0].id); + duplicating.then(onDuplicated, onError); + } +} + +// Query for all open tabs +var querying = browser.tabs.query({}); +querying.then(duplicateFirstTab, onError);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromiums の <a href="https://developer.chrome.com/extensions/tabs#method-duplicate"><code>chrome.tabs</code></a> APIに基づいています。 This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p> + +<p>Microsoft Edge での実装状況は Microsoft Corporation から提供されたものであり、ここでは Creative Commons Attribution 3.0 United States License に従っています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/executescript/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/executescript/index.html new file mode 100644 index 0000000000..82e1ee1686 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/executescript/index.html @@ -0,0 +1,176 @@ +--- +title: tabs.executeScript() +slug: Mozilla/Add-ons/WebExtensions/API/tabs/executeScript +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - executeScript + - tabs +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/executeScript +--- +<div>{{AddonSidebar()}}</div> + +<p>JavaScript のコードをページに挿入します。</p> + +<p>コードを挿入できるページの URL は、<a href="/ja/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">マッチパターン</a> により指定できます。 つまり、URL の scheme 部は、"http", "https", "file", "ftp" のいずれかでなければなりません。そして、その URL に対する明示的な <a href="https://developer.mozilla.org/ja/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">host パーミッション</a>、または <a href="/ja/Add-ons/WebExtensions/manifest.json/permissions#activeTab_permission">activeTab パーミッション</a>が必要です。</p> + +<p>また、自らの拡張機能パッケージに含まれるページに対してであれば、次の方法でコードを挿入することも可能です。</p> + +<pre class="brush: js">browser.tabs.create({url: "/my-page.html"}).then(() => { + browser.tabs.executeScript({ + code: `console.log('location:', window.location.href);` + }); +});</pre> + +<p>この場合、特別なパーミッションは必要ありません。</p> + +<p>ブラウザーの組込ページ、例えば about:debugging、about:addons、新規タブを開いた時のページなどには、コードを挿入することは<em>できません</em>。</p> + +<p>挿入するスクリプトのことを、コンテンツスクリプトと呼びます。詳細は <a href="/ja/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">コンテンツスクリプト</a> で学んでください。</p> + +<p>これは、<code><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> を返す非同期関数です。</p> + +<h2 id="構文">構文</h2> + +<pre class="syntaxbox brush:js">var executing = browser.tabs.executeScript( + tabId, // optional integer + details // object +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>tabId</code> {{optional_inline}}</dt> + <dd><code>integer</code> 型。 スクリプトを実行するタブの ID。省略時のデフォルトは、現在のウィンドウでアクティブなタブ。</dd> + <dt><code>details</code></dt> + <dd>実行するスクリプトに関するオブジェクト。次のプロパティを持ちます。</dd> + <dd> + <dl class="reference-values"> + <dt><code>allFrames</code> {{optional_inline}}</dt> + <dd><code>boolean</code> 型。<code>true</code> である場合は、現在のページが持つ全てのフレームにコードが挿入されます。<code>true</code> であり、かつ <code>frameId</code> が設定されている場合はエラーが発生するため、frameId と allFrames は互いに排他的です。<code>false</code> である場合は、最上位のフレームにのみコードが挿入されます。デフォルトは <code>false</code> です。</dd> + <dt><code>code</code> {{optional_inline}}</dt> + <dd><code>string</code> 型。挿入されるコードを文字列として表現したもの。<strong>注意:</strong> このプロパティを使って信頼できないデータを JavaScript に挿入しないでください。セキュリティの問題につながります。</dd> + <dt><code>file</code> {{optional_inline}}</dt> + <dd><code>string</code> 型。挿入されるコードを持つファイルへのパス。Firefox では、拡張機能のルートから始まらない相対 URL は、現在のページの URL からの相対位置として解決されます。Chrome では、そのような URL は拡張機能のベース URL からの相対位置として解決されます。複数のブラウザーで動作させるには、拡張機能のルートから始まる相対 URL として指定します。例えば、<code>"/path/to/script.js"</code> のようにします。</dd> + <dt><code>frameId</code> {{optional_inline}}</dt> + <dd><code>integer</code> 型。コードが挿入されるフレーム。デフォルトは <code>0</code> (最上位のフレーム) です。</dd> + <dt><code>matchAboutBlank</code> {{optional_inline}}</dt> + <dd><code>boolean</code> 型。<code>true</code> である場合、コードはその親ドキュメントへのアクセスをもつときに、組込の "about:blank" や "about:srcdoc" フレームにも挿入されます。コードをトップレベルの about: フレームに挿入することはできません。デフォルトは <code>false</code> です。</dd> + <dt><code>runAt</code> {{optional_inline}}</dt> + <dd>{{WebExtAPIRef('extensionTypes.RunAt')}} 型。コードがどの時点でタブに挿入されるかを指定します。デフォルトは "document_idle" です。</dd> + </dl> + </dd> +</dl> + +<h3 id="戻り値">戻り値</h3> + +<p>オブジェクト配列を使って fulfilled 状態にされる <code><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> です。それぞれのオブジェクトは、フレームに挿入されたスクリプトの結果を表します。</p> + +<p>スクリプトの結果とは最後に評価された文のことです。これは、<a href="/ja/docs/Tools/Web_Console">Webコンソール</a>で実行されたスクリプトの出力 (結果であって、<code>console.log()</code> の出力のことではありません) に似ています。例えば、次のようなスクリプトを挿入したとします。</p> + +<pre class="brush: js">var foo='my result';foo;</pre> + +<p>この場合、結果配列には、文字列 "<code>my result</code>" が含まれます。結果は、<a href="/ja/docs/Web/API/Web_Workers_API/Structured_clone_algorithm">structured clone</a> が可能でなければなりません。最後の文を <code><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> にすることもできますが、<a href="https://github.com/mozilla/webextension-polyfill#tabsexecutescript">webextension-polyfill</a> ライブラリではサポートされていません。</p> + +<p>エラーが発生した場合、Promise はエラーメッセージを使って rejected 状態にされます。</p> + +<h2 id="使用例">使用例</h2> + +<p>次の例は、現在アクティブなタブで 1 行のコードスニペットを実行します。</p> + +<pre class="brush: js">function onExecuted(result) { + console.log(`グリーンにしました`); +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var makeItGreen = 'document.body.style.border = "5px solid green"'; + +var executing = browser.tabs.executeScript({ + code: makeItGreen +}); +executing.then(onExecuted, onError);</pre> + +<p>次の例は、ファイルからスクリプトを実行します。このファイルは拡張機能のパッケージに含まれており、"content-script.js" という名前です。そのスクリプトは、現在アクティブなタブで実行されますが、メインのドキュメントだけでなく、全てのサブフレームでも実行されます。</p> + +<pre class="brush: js">function onExecuted(result) { + console.log(`全てのサブフレームで実行しました`); +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var executing = browser.tabs.executeScript({ + file: "/content-script.js", + allFrames: true +}); +executing.then(onExecuted, onError);</pre> + +<p>次の例は、ファイルからスクリプトを実行します。このファイルは拡張機能のパッケージに含まれており、"content-script.js" という名前です。そのスクリプトは、ID が 2 であるタブで実行されます。</p> + +<pre class="brush: js">function onExecuted(result) { + console.log(`タブ 2 で実行しました`); +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var executing = browser.tabs.executeScript( + 2, { + file: "/content-script.js" +}); +executing.then(onExecuted, onError);</pre> + +<p>{{WebExtExamples}}</p> + +<h2 id="ブラウザー実装状況">ブラウザー実装状況</h2> + + + +<p>{{Compat("webextensions.api.tabs.executeScript")}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/tabs#method-executeScript"><code>chrome.tabs</code></a> API に基づいています。このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> における Chromium のコードに基づいています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/get/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/get/index.html new file mode 100644 index 0000000000..767b11173d --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/get/index.html @@ -0,0 +1,87 @@ +--- +title: tabs.get() +slug: Mozilla/Add-ons/WebExtensions/API/tabs/get +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/get +--- +<div>{{AddonSidebar()}}</div> + +<p>タブのIDを指定し、{{WebExtAPIRef("tabs.Tab")}}オブジェクトとしてタブの詳細を取得します。</p> + +<p>これは<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>を返す非同期関数です。</p> + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox brush:js">var getting = browser.tabs.get( + tabId // integer +) +</pre> + +<h3 id="Parameters">Parameters</h3> + +<dl> + <dt><code>tabId</code></dt> + <dd><code>integer</code>. 取得するタブのID。</dd> +</dl> + +<h3 id="Return_value">Return value</h3> + +<p>A <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that will be fulfilled with a {{WebExtAPIRef('tabs.Tab')}} object containing information about the tab. If the tab could not be found or some other error occurs, the promise will be rejected with an error message.</p> + +<h2 id="Examples">Examples</h2> + +<p>タブがアクティブなとき、情報を取得します:</p> + +<pre class="brush: js">async function logListener(info) { + try { + let tabInfo = await browser.tabs.get(info.tabId); + console.log(tabInfo); + } catch (error) { + console.error(error); + } +} + +browser.tabs.onActivated.addListener(logListener);</pre> + +<p>{{WebExtExamples}}</p> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("webextensions.api.tabs.get")}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs#method-get"><code>chrome.tabs</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/index.html new file mode 100644 index 0000000000..40f6ced315 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/index.html @@ -0,0 +1,215 @@ +--- +title: tabs +slug: Mozilla/Add-ons/WebExtensions/API/tabs +tags: + - API + - Add-ons + - Extensions + - Interface + - Non-standard + - Reference + - WebExtensions + - tabs + - タブ +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs +--- +<div>{{AddonSidebar}}</div> + +<p>ブラウザーのタブシステムとやりとりします。</p> + +<p>この API を使って開いているタブの一覧を取得したり、いろいろな条件でフィルターしたり、タブを開き、更新し、移動し、再読み込みし、削除できます。この API ではタブのコンテンツに直接アクセスできませんが、JavaScript と CSS をタブに挿入することは、{{WebExtAPIRef("tabs.executeScript()")}} や {{WebExtAPIRef("tabs.insertCSS()")}} API を使ってできます。</p> + +<p>この API の大半の使用に特別なパーミッションは要りませんが:</p> + +<ul> + <li><code>Tab.url</code> <code>Tab.title</code> <code>Tab.favIconUrl</code>, のアクセスには "tabs" <a href="https://developer.mozilla.org/ja/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">パーミッション</a>が必要です。また Firefox では URL による{{WebExtAPIRef("tabs.query", "問い合わせ")}}をするのにも "tabs" が必要です。</li> + <li>{{WebExtAPIRef("tabs.executeScript()")}} や {{WebExtAPIRef("tabs.insertCSS()")}} を使うには、そのタブの <a href="/ja/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">host パーミッション</a>が必要です。</li> +</ul> + +<p>あるいは、これらのパーミッションを一時的に取得することもできますが、それは現在アクティブなタブで明示的なユーザーアクションへの応答する場合のみで、<a href="/ja/Add-ons/WebExtensions/manifest.json/permissions#activeTab_permission">"activeTab" パーミッション</a>を要求することで可能です。</p> + +<p>タブ操作の多くはタブ ID を使います。タブ ID はブラウザーセッションの単一のタブごとにユニークである保証がされています。ブラウザーが再起動したら、タブ ID を再利用できて、実際そうします。ブラウザーの再起動をまたいでタブ情報を関連づけるには {{WebExtAPIRef("sessions.setTabValue()")}} を使います。</p> + +<h2 id="Types" name="Types">型</h2> + +<dl> + <dt>{{WebExtAPIRef("tabs.MutedInfoReason")}}</dt> + <dd>タブがミュートされている、またはミュートが解除されている理由を示す。</dd> + <dt>{{WebExtAPIRef("tabs.MutedInfo")}}</dt> + <dd>タブがミュートされているかを示す真理値と、最後の変更の理由からなるオブジェクト。</dd> + <dt>{{WebExtAPIRef("tabs.PageSettings")}}</dt> + <dd> + <p><a href="https://developer.mozilla.org/ja/docs/Mozilla/Add-ons/WebExtensions/API/tabs/saveAsPDF" title="Saves the current page as a PDF. This will open a dialog, supplied by the underlying operating system, asking the user where they want to save the PDF."><code>tabs.saveAsPDF()</code></a>メソッドにおいて、どのように PDF を描画するかを制御する。</p> + </dd> + <dt>{{WebExtAPIRef("tabs.Tab")}}</dt> + <dd>タブについての情報を含む。</dd> + <dt>{{WebExtAPIRef("tabs.TabStatus")}}</dt> + <dd>タブの読み込み状況を示す。</dd> + <dt>{{WebExtAPIRef("tabs.WindowType")}}</dt> + <dd>タブを所有しているウィンドウのタイプを示す。</dd> + <dt>{{WebExtAPIRef("tabs.ZoomSettingsMode")}}</dt> + <dd>ズームがブラウザーによるものか、拡張機能によるものか、またはズームが許可されていないのかを示す。</dd> + <dt>{{WebExtAPIRef("tabs.ZoomSettingsScope")}}</dt> + <dd>あるページのズームが、同一生成元の別ページにも適用されるか、タブ内でのみかを示す。</dd> + <dt>{{WebExtAPIRef("tabs.ZoomSettings")}}</dt> + <dd>ズーム設定{{WebExtAPIRef("tabs.ZoomSettingsMode", "mode")}}, {{WebExtAPIRef("tabs.ZoomSettingsScope", "scope")}}とデフォルトのズーム要因を示す。</dd> +</dl> + +<h2 id="Properties" name="Properties">プロパティ</h2> + +<dl> + <dt>{{WebExtAPIRef("tabs.TAB_ID_NONE")}}</dt> + <dd>ブラウザーのタブでないタブに対する特殊な ID(Windows の開発ツールなど)。</dd> +</dl> + +<h2 id="Functions" name="Functions">関数</h2> + +<dl> + <dt>{{WebExtAPIRef("tabs.captureTab()")}}</dt> + <dd>あるタブの可視エリアの画像をエンコードしたデータURIを作成します。</dd> + <dt>{{WebExtAPIRef("tabs.captureVisibleTab()")}}</dt> + <dd>特定のウィンドウのアクティブなタブの可視エリアの画像をエンコードしたデータURI を作成します。</dd> + <dt>{{WebExtAPIRef("tabs.connect()")}}</dt> + <dd>あるタブにおいて、バックグラウンドスクリプト(またはその他ポップアップやオプションページのスクリプトなど特権スクリプト)と <a href="https://developer.mozilla.org/ja/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">content scripts</a> 間でのメッセージのやり取り用の経路を確保します。</dd> + <dt>{{WebExtAPIRef("tabs.create()")}}</dt> + <dd>新しいタブを作る。</dd> + <dt>{{WebExtAPIRef("tabs.detectLanguage()")}}</dt> + <dd>タブのコンテンツの言語を検出する</dd> + <dt>{{WebExtAPIRef("tabs.discard()")}}</dt> + <dd>1つ以上のタブを破棄する。</dd> + <dt>{{WebExtAPIRef("tabs.duplicate()")}}</dt> + <dd>タブを複製する。</dd> + <dt>{{WebExtAPIRef("tabs.executeScript()")}}</dt> + <dd>ページに JavaScript コードを挿入する。</dd> + <dt>{{WebExtAPIRef("tabs.get()")}}</dt> + <dd>特定のタブについて情報を取り出す。</dd> + <dt>{{WebExtAPIRef("tabs.getAllInWindow()")}} {{deprecated_inline}}</dt> + <dd>特定のウィンドウ内のすべてのタブについての情報を取り出す。</dd> + <dt>{{WebExtAPIRef("tabs.getCurrent()")}}</dt> + <dd>スクリプトが実行されているタブについての情報を <a href="https://developer.mozilla.org/ja/docs/Mozilla/Add-ons/WebExtensions/API/Tabs/Tab" title="This type contains information about a tab."><code>tabs.Tab</code></a> オブジェクトとして取り出す。</dd> + <dt>{{WebExtAPIRef("tabs.getSelected()")}} {{deprecated_inline}}</dt> + <dd>あるウィンドウにおいてタブが選択されているかを得る。</dd> + <dt>{{WebExtAPIRef("tabs.getZoom()")}}</dt> + <dd>あるタブについてズーム要因を得る。</dd> + <dt>{{WebExtAPIRef("tabs.getZoomSettings()")}}</dt> + <dd>あるタブについてズーム設定を得る。</dd> + <dt>{{WebExtAPIRef("tabs.goForward()")}}</dt> + <dd>可能な場合、次のページへ進む。</dd> + <dt>{{WebExtAPIRef("tabs.goBack()")}}</dt> + <dd>可能な場合、前のページへ戻る。</dd> + <dt>{{WebExtAPIRef("tabs.hide()")}} {{experimental_inline}}</dt> + <dd>1つ以上のタブを隠す。</dd> + <dt>{{WebExtAPIRef("tabs.highlight()")}}</dt> + <dd>1 つ以上のタブをハイライトする。</dd> + <dt>{{WebExtAPIRef("tabs.insertCSS()")}}</dt> + <dd>CSS をページに挿入する。</dd> + <dt>{{WebExtAPIRef("tabs.move()")}}</dt> + <dd>2 つ以上のタブを同じ、あるいは異なるウィンドウの任意のポジションへ移動させる。</dd> + <dt>{{WebExtApiRef("tabs.moveInSuccession()")}}</dt> + <dd>タブグループの継承関係を編集する。</dd> + <dt>{{WebExtAPIRef("tabs.print()")}}</dt> + <dd>開いているタブのコンテンツを印刷する。</dd> + <dt>{{WebExtAPIRef("tabs.printPreview()")}}</dt> + <dd> + <div>開いているタブの印刷プレビューを開く。</div> + </dd> + <dt>{{WebExtAPIRef("tabs.query()")}}</dt> + <dd>特定のプロパティを持つすべてのタブ、またはプロパティが指定されなければすべてのタブを取得します。</dd> + <dt>{{WebExtAPIRef("tabs.reload()")}}</dt> + <dd>タブをリロードする。キャッシュを回避することもできる。</dd> + <dt>{{WebExtAPIRef("tabs.remove()")}}</dt> + <dd>1つ以上のタブを閉じる。</dd> + <dt>{{WebExtAPIRef("tabs.removeCSS()")}}</dt> + <dd>以前に{{WebExtAPIRef("tabs.insertCSS()")}}を呼び出して挿入されているCSSを削除する。</dd> + <dt>{{WebExtAPIRef("tabs.saveAsPDF()")}}</dt> + <dd>現在のページを PDF として保存する。</dd> + <dt>{{WebExtAPIRef("tabs.sendMessage()")}}</dt> + <dd>あるタブのコンテンツスクリプトへ、1つのメッセージを送信する。</dd> + <dt>{{WebExtAPIRef("tabs.sendRequest()")}} {{deprecated_inline}}</dt> + <dd>あるタブのコンテンツスクリプトへ、単一のリクエストを送信する。<strong>非推奨</strong>: 代わりに {{WebExtAPIRef("tabs.sendMessage()")}} を使用してください。</dd> + <dt>{{WebExtAPIRef("tabs.setZoom()")}}</dt> + <dd>あるタブをズームする。</dd> + <dt>{{WebExtAPIRef("tabs.setZoomSettings()")}}</dt> + <dd>あるタブについてズーム設定をする。</dd> + <dt>{{WebExtAPIRef("tabs.show()")}} {{experimental_inline}}</dt> + <dd>{{WebExtAPIRef("tabs.hide()", "hidden")}}で隠されたタブを表示する。</dd> + <dt>{{WebExtAPIRef("tabs.toggleReaderMode()")}}</dt> + <dd>あるタブについてのリーダーモードへのトグル。</dd> + <dt>{{WebExtAPIRef("tabs.update()")}}</dt> + <dd>新しい URL に案内、もしくはタブの他のプロパティを修正する。</dd> +</dl> + +<h2 id="Events" name="Events">イベント</h2> + +<dl> + <dt>{{WebExtAPIRef("tabs.onActivated")}}</dt> + <dd>ウィンドウ内でアクティブなタブが変わったときに発火。このイベントが発火した段階ではまだタブの URL はセットされているとは限らない。</dd> + <dt>{{WebExtAPIRef("tabs.onActiveChanged")}} {{deprecated_inline}}</dt> + <dd>ウィンドウの中の選択されたタブが変更されたときに発火。<strong>非推奨:</strong> 代わりに{{WebExtAPIRef("tabs.onActivated")}}を利用してください。</dd> + <dt>{{WebExtAPIRef("tabs.onAttached")}}</dt> + <dd>タブがウィンドウに引っ付けられたとき、例えばウィンドウ間で移動されたときに発火。</dd> + <dt>{{WebExtAPIRef("tabs.onCreated")}}</dt> + <dd>タブが作られたときに発火。このイベントが発火した段階ではまだタブの URL はセットされているとは限らない。</dd> + <dt>{{WebExtAPIRef("tabs.onDetached")}}</dt> + <dd>タブがウィンドウから切り離されたときに発火。例えば、ウィンドウのない場所へタブを移動させたときなど。</dd> + <dt>{{WebExtAPIRef("tabs.onHighlightChanged")}} {{deprecated_inline}}</dt> + <dd>ウィンドウ内でハイライトまたは選択されたタブが変更したときに発火。<strong>非推奨:</strong> 代わりに{{WebExtAPIRef("tabs.onHighlighted")}}を使用してください。</dd> + <dt>{{WebExtAPIRef("tabs.onHighlighted")}}</dt> + <dd>ウィンドウ内でハイライトまたは選択されたタブが変更したときに発火。</dd> + <dt>{{WebExtAPIRef("tabs.onMoved")}}</dt> + <dd>ウィンドウ内にタブが移動したときに発火する。</dd> + <dt>{{WebExtAPIRef("tabs.onRemoved")}}</dt> + <dd>タブが閉じられたときに発火する。</dd> + <dt>{{WebExtAPIRef("tabs.onReplaced")}}</dt> + <dd>プリレンダリングによってタブが他のタブに置き換えられたときに発火。</dd> + <dt>{{WebExtAPIRef("tabs.onSelectionChanged")}} {{deprecated_inline}}</dt> + <dd>ウィンドウ内で選択されているタブが変わったときに発火。<strong>非推奨:</strong> 代わりに{{WebExtAPIRef("tabs.onActivated")}}を使用してください。</dd> + <dt>{{WebExtAPIRef("tabs.onUpdated")}}</dt> + <dd>タブが更新されたときに発火する。</dd> + <dt>{{WebExtAPIRef("tabs.onZoomChange")}}</dt> + <dd>タブがズームされたときに発火する。</dd> +</dl> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザー実装状況</h2> + +<p>{{Compat("webextensions.api.tabs")}}</p> + +<p>{{WebExtExamples("h2")}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs"><code>chrome.tabs</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p> + +<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p> +</div> + +<div class="hidden"> +<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/mutedinfo/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/mutedinfo/index.html new file mode 100644 index 0000000000..7d70c895e8 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/mutedinfo/index.html @@ -0,0 +1,67 @@ +--- +title: tabs.MutedInfo +slug: Mozilla/Add-ons/WebExtensions/API/tabs/MutedInfo +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/MutedInfo +--- +<div>{{AddonSidebar()}}</div> + +<p>This object contains a boolean indicating whether the tab is muted, and the reason for the last state change.</p> + +<h2 id="型">型</h2> + +<p>値の型はオブジェクトです。次のプロパティを含みます:</p> + +<dl class="reference-values"> + <dt><code>extensionId</code>{{optional_inline}}</dt> + <dd><code>string</code>. ミュートの状態を最後に変更した拡張機能のIDです。もし拡張機能がミュートの状態の最後の変更の理由でないなら設定されません。</dd> + <dt><code>muted</code></dt> + <dd><code>boolean</code>. タブが現在ミュートかどうか。Equivalent to whether the muted audio indicator is showing.</dd> + <dt><code>reason</code>{{optional_inline}}</dt> + <dd>{{WebExtAPIRef('tabs.MutedInfoReason')}}. ミュートもしくはアンピューとに設定された理由。Not set if the tab's muted state has never been changed.</dd> +</dl> + +<h2 id="ブラウザ互換性">ブラウザ互換性</h2> + + + +<p>{{Compat("webextensions.api.tabs.MutedInfo")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs#type-MutedInfo"><code>chrome.tabs</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p> + +<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/mutedinforeason/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/mutedinforeason/index.html new file mode 100644 index 0000000000..3a838233b6 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/mutedinforeason/index.html @@ -0,0 +1,67 @@ +--- +title: tabs.MutedInfoReason +slug: Mozilla/Add-ons/WebExtensions/API/tabs/MutedInfoReason +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/MutedInfoReason +--- +<div>{{AddonSidebar()}}</div> + +<p>タブがミュート・アンミュートになった理由を指定します。</p> + +<h2 id="型">型</h2> + +<p>値のタイプは文字列型です。可能な値:</p> + +<dl> + <dt>"capture"</dt> + <dd>タブのキャプチャが開始され、ミュート状態に強いられました。</dd> + <dt>"extension"</dt> + <dd>拡張機能がミュート状態に設定しました。もしこれが理由なら、{{WebExtAPIRef("tabs.mutedInfo")}}の<code>extensionId</code>が責任のある拡張機能のIDを含んでいます。</dd> + <dt>"user"</dt> + <dd>ユーザがミュート状態に設定しました。</dd> +</dl> + +<h2 id="ブラウザ互換性">ブラウザ互換性</h2> + + + +<p>{{Compat("webextensions.api.tabs.MutedInfoReason")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>このAPIはChromiumの<a href="https://developer.chrome.com/extensions/tabs#type-MutedInfoReason"><code>chrome.tabs</code></a> APIに基づいています。このドキュメントはChromiumコードの<a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a>から派生したものです。</p> + +<p>Microsoft Edgeの互換性データはMicrosoft Corporationから提供されており、Creative Commons Attribution 3.0 United States Licenseのもとにここに含まれています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/oncreated/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/oncreated/index.html new file mode 100644 index 0000000000..2113436fa6 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/oncreated/index.html @@ -0,0 +1,100 @@ +--- +title: tabs.onCreated +slug: Mozilla/Add-ons/WebExtensions/API/tabs/onCreated +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/onCreated +--- +<div>{{AddonSidebar()}}</div> + +<p>タブが生成されたときに発火します。</p> + +<p>イベントが発火したとき、タブはURLを渡されていないかもしれないことに注意してください。特に、Firefoxは新しいページを読み込み前に新しいタブを"about:blank"で開きます。URLがセットされたときを通知されるために{{WebExtAPIRef("tabs.onUpdated")}}イベントをリッスンすることができます。</p> + +<h2 id="書式">書式</h2> + +<pre class="syntaxbox brush:js">browser.tabs.onCreated.addListener(callback) +browser.tabs.onCreated.removeListener(listener) +browser.tabs.onCreated.hasListener(listener) +</pre> + +<p>イベントは3つの関数を持ちます:</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>このイベントにリスナーを追加します。</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>このイベントのリスニングを停止します。引数<code>listener</code>は削除するリスナーです。</dd> + <dt><code>hasListener(listener)</code></dt> + <dd><code>listener</code>がこのイベントに登録されているかを調べます。リスニング中であれば<code>true</code>を返し、そうでなければ<code>false</code>を返します</dd> +</dl> + +<h2 id="addListenerの書式">addListenerの書式</h2> + +<h3 id="パラメータ">パラメータ</h3> + +<dl> + <dt><code>callback</code></dt> + <dd> + <p>このイベントが発生したときに呼び出される関数です。関数は次の引数を渡されます:</p> + + <dl class="reference-values"> + <dt><code>tab</code></dt> + <dd>{{WebExtAPIRef('tabs.Tab')}}。生成されたタブの詳細です。</dd> + </dl> + </dd> +</dl> + +<h2 id="例">例</h2> + +<p>新しく作られたタブのログを生成します:</p> + +<pre class="brush: js">function handleCreated(tab) { + console.log(tab.id); +} + +browser.tabs.onCreated.addListener(handleCreated);</pre> + +<p>{{WebExtExamples}}</p> + +<h2 id="ブラウザ互換性">ブラウザ互換性</h2> + + + +<p>{{Compat("webextensions.api.tabs.onCreated")}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>このAPIはChromiumの<a href="https://developer.chrome.com/extensions/tabs#event-onCreated"><code>chrome.tabs</code></a> APIに基づいています。このドキュメンテーションはChromium codeの中の<a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a>からの派生です。</p> + +<p>Microsoft Edgeの互換性データはMicrosoft Corporationから提供されており、ここにthe Creative Commons Attribution 3.0 United States Licenseのもとで含まれています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/query/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/query/index.html new file mode 100644 index 0000000000..9b8dfc5a2a --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/query/index.html @@ -0,0 +1,216 @@ +--- +title: tabs.query() +slug: Mozilla/Add-ons/WebExtensions/API/tabs/query +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/query +--- +<div>{{AddonSidebar()}}</div> + +<p>指定されたプロパティを持つ全てのタブを取得します。何も指定しない場合、全てのタブを取得します。</p> + +<p>この関数は <code><a href="/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> を返す非同期関数です。</p> + +<h2 id="構文">構文</h2> + +<pre class="syntaxbox brush:js notranslate">var querying = browser.tabs.query( + queryInfo // object +) +</pre> + +<h3 id="パラメータ">パラメータ</h3> + +<dl> + <dt><code>queryInfo</code></dt> + <dd><code>object</code>. <code>query()</code> 関数はここで指定されたプロパティにマッチするタブだけを取得します。 このプロパティについての詳細は {{WebExtAPIRef("tabs.Tab")}} を参照してください。</dd> + <dd> + <dl class="reference-values"> + <dt><code>active</code>{{optional_inline}}</dt> + <dd><code>boolean</code>. 各ウインドウの中でアクティブかどうか。</dd> + <dt><code>audible</code>{{optional_inline}}</dt> + <dd><code>boolean</code>. 音が鳴っているか。</dd> + <dt><code>autoDiscardable</code>{{optional_inline}}</dt> + <dd><code>boolean</code>. リソースが少なくなったときにブラウザーによって自動的にdiscardできるか。</dd> + <dt><code>cookieStoreId</code> {{optional_inline}}</dt> + <dd><code>string</code>. CookieストアのIDが <code>cookieStoreId</code> なタブのみを返すために使います。このオプションは <code>"cookies"</code> <a href="/ja/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>を持つ拡張でのみ使用できます。</dd> + <dt><code>currentWindow</code>{{optional_inline}}</dt> + <dd><code>boolean</code>. カレントウインドウの中のタブか。</dd> + <dt><code>discarded</code>{{optional_inline}}</dt> + <dd><code>boolean</code>. タブがdiscardされているか。 discardされたタブはコンテンツがメモリからアンロードされているが、タブの一覧には表示されたままになります。コンテンツはタブが次にアクティブになったときにリロードされます。</dd> + <dt><code>highlighted</code>{{optional_inline}}</dt> + <dd><code>boolean</code>. ハイライトされているか。</dd> + <dt><code>index</code>{{optional_inline}}</dt> + <dd><code>integer</code>. ウィンドウの中での位置。</dd> + <dt><code>muted</code>{{optional_inline}}</dt> + <dd><code>boolean</code>. ミュートされているか。</dd> + <dt><code>lastFocusedWindow</code>{{optional_inline}}</dt> + <dd><code>boolean</code>. 最後にフォーカスされたウインドウのタブか。</dd> + <dt><code>openerTabId</code>{{optional_inline}}</dt> + <dd><code>integer</code>. そのタブを開いたタブのID。</dd> + <dt><code>pinned</code>{{optional_inline}}</dt> + <dd><code>boolean</code>. ピン留めされているか。</dd> + <dt><code>status</code>{{optional_inline}}</dt> + <dd>{{WebExtAPIRef('tabs.TabStatus')}}. ロードが完了しているか。</dd> + <dt><code>title</code>{{optional_inline}}</dt> + <dd><code>string</code>. ページのタイトル。</dd> + <dt><code>url</code>{{optional_inline}}</dt> + <dd><code><code>string</code></code> もしくは <code><code>array</code> of <code><code>string</code></code></code>. 1つ以上の<a href="/ja/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">マッチパターン</a>にマッチするタブか。フラグメント識別子にはマッチしません。</dd> + <dt><code>windowId</code>{{optional_inline}}</dt> + <dd><code>integer</code>. そのウインドウのID。カレントウインドウの場合は、 {{WebExtAPIRef('windows.WINDOW_ID_CURRENT')}} 。</dd> + <dt><code>windowType</code>{{optional_inline}}</dt> + <dd>{{WebExtAPIRef('tabs.WindowType')}}. そのタブの属するウインドウの種類。</dd> + </dl> + </dd> +</dl> + +<h3 id="戻り値">戻り値</h3> + +<p>マッチしたタブの情報を持つ <code>{{WebExtAPIRef('tabs.Tab')}}</code> オブジェクトの <code>array</code> に解決される <code><a href="/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>。</p> + +<p>エラーが発生した場合、その Promise はエラーメッセージとともに却下されます。</p> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</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.api.tabs.query", 10)}}</p> + +<h2 id="例">例</h2> + +<p>全てのタブを取得する例:</p> + +<pre class="brush: js notranslate">function logTabs(tabs) { + for (let tab of tabs) { + // tab.url requires the `tabs` permission + console.log(tab.url); + } +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var querying = browser.tabs.query({}); +querying.then(logTabs, onError);</pre> + +<p>カレントウインドウの全てのタブを取得する例:</p> + +<pre class="brush: js notranslate">function logTabs(tabs) { + for (let tab of tabs) { + // tab.url requires the `tabs` permission + console.log(tab.url); + } +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var querying = browser.tabs.query({currentWindow: true}); +querying.then(logTabs, onError);</pre> + +<p>カレントウインドウのアクティブなタブを取得する例:</p> + +<pre class="brush: js notranslate">function logTabs(tabs) { + for (let tab of tabs) { + // tab.url requires the `tabs` permission + console.log(tab.url); + } +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var querying = browser.tabs.query({currentWindow: true, active: true}); +querying.then(logTabs, onError);</pre> + +<p>"mozilla.org" またはそのサブドメイン下のHTTP/HTTPS URLを開いている全てのタブを取得する例:</p> + +<pre class="brush: js notranslate">function logTabs(tabs) { + for (let tab of tabs) { + // tab.url requires the `tabs` permission + console.log(tab.url); + } +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var querying = browser.tabs.query({url: "*://*.mozilla.org/*"}); +querying.then(logTabs, onError);</pre> + +<p>moz-extension:// URLを開いている全てのタブを取得する例:</p> + +<pre class="brush: js notranslate">function logTabs(tabs) { + console.log(tabs); + for (let tab of tabs) { + // tab.url requires the `tabs` permission + console.log(tab.url); + } +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var querying = browser.tabs.query({url: "moz-extension://*/*"}); +querying.then(logTabs, onError); +</pre> + +<p>この拡張機能のURLを開いている全てのタブを取得する例:</p> + +<pre class="brush: js notranslate">function logTabs(tabs) { + console.log(tabs); + for (let tab of tabs) { + // tab.url requires the `tabs` permission + console.log(tab.url); + } +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var querying = browser.tabs.query({url: browser.extension.getURL("*")}); +querying.then(logTabs, onError); +</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>この API は Chromium の <a class="external external-icon" href="https://developer.chrome.com/extensions/tabs#method-duplicate"><code>chrome.tabs</code></a> APIに基づいています。 This documentation is derived from <a class="external external-icon" href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p> + +<p>Microsoft Edge での実装状況は Microsoft Corporation から提供されたものであり、ここでは Creative Commons Attribution 3.0 United States License に従っています。</p> +</div> + +<div class="hidden"> +<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/remove/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/remove/index.html new file mode 100644 index 0000000000..16c3419265 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/remove/index.html @@ -0,0 +1,102 @@ +--- +title: tabs.remove() +slug: Mozilla/Add-ons/WebExtensions/API/tabs/remove +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/remove +--- +<div>{{AddonSidebar()}}</div> + +<p>1つ以上のタブを閉じます。</p> + +<p>この関数は <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> を返す非同期関数です。</p> + +<h2 id="構文">構文</h2> + +<pre class="syntaxbox brush:js">var removing = browser.tabs.remove( + tabIds // integer or integer array +) +</pre> + +<h3 id="パラメータ">パラメータ</h3> + +<dl> + <dt><code>tabIds</code></dt> + <dd><code><code>integer</code></code> または <code><code>array</code> of <code><code>integer</code></code></code>. 閉じるタブのIDを指定します。</dd> +</dl> + +<h3 id="戻り値">戻り値</h3> + +<p>A <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that will be fulfilled with no arguments when all the specified tabs have been removed or their <code>beforeunload</code> prompts have been handled. If any error occurs, the promise will be rejected with an error message.</p> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</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.api.tabs.remove")}}</p> + +<h2 id="例">例</h2> + +<p>タブを1つだけ閉じる場合:</p> + +<pre class="brush: js">function onRemoved() { + console.log(`Removed`); +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var removing = browser.tabs.remove(2); +removing.then(onRemoved, onError);</pre> + +<p>複数のタブを閉じる場合:</p> + +<pre class="brush: js">function onRemoved() { + console.log(`Removed`); +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var removing = browser.tabs.remove([15, 14, 1]); +removing.then(onRemoved, onError);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/tabs#method-remove"><code>chrome.tabs</code></a> APIに基づいています。 This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p> + +<p>Microsoft Edge での実装状況は Microsoft Corporation から提供されたものであり、ここでは Creative Commons Attribution 3.0 United States License に従っています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/tabs/tab/index.html b/files/ja/mozilla/add-ons/webextensions/api/tabs/tab/index.html new file mode 100644 index 0000000000..fcab149353 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/tabs/tab/index.html @@ -0,0 +1,128 @@ +--- +title: tabs.Tab +slug: Mozilla/Add-ons/WebExtensions/API/tabs/Tab +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/Tab +--- +<div>{{AddonSidebar()}}</div> + +<p><strong><code>tabs.Tab</code></strong>型はタブについての情報を含んでいます。これはタブの中のコンテンツについての情報へのアクセスを提供します。例えば、コンテンツはどれくらいの大きさか、どのような特別な状態もしくは制限が有効になっているか、など。</p> + +<h2 id="Type">Type</h2> + +<p>この型の値はオブジェクトです。以下のプロパティを含みます:</p> + +<dl class="reference-values"> + <dt><code>active</code></dt> + <dd> + <p><code>boolean</code>. タブがウィンドウ内でアクティブかどうかを示します。タブのウィンドウがフォーカスされていない場合でも当てはまります。</p> + + <p>アクティブなタブは通常一つ検出されます。しかしながら、Firefox for Android上では、拡張機能のポップアップが新しいタブの中で開かれます。このポップアップタブが検出されたとき、アクティブなタブはポップアップが開かれたタブに代えられます。</p> + </dd> + <dt><code>attention</code> {{optional_inline}}</dt> + <dd><code>boolean</code>. タブが注目を集めているかを示します。例えば、タブがモーダルダイアログを表示したとき、<code>attention</code>は<code>true</code>になります。</dd> + <dt><code>audible</code> {{optional_inline}}</dt> + <dd><code>boolean</code>. タブがミュートではないとき: タブが音を作り出すかどうかです。タブがミュートであるとき: タブがミュートでないなら、音を作り出せたかどうかです。</dd> + <dt><code>autoDiscardable</code> {{optional_inline}}</dt> + <dd><code>boolean</code>. Whether the tab can be discarded automatically by the browser when resources are low.</dd> + <dt><code>cookieStoreId</code> {{optional_inline}}</dt> + <dd><code>string</code>. タブのクッキーストア。If different tabs can have different cookie stores (for example, to support <a href="https://wiki.mozilla.org/Security/Contextual_Identity_Project/Containers">contextual identity</a>), you can pass this as the <code>storeId</code> option into various methods of the {{WebExtAPIRef("cookies")}} API, to set and get cookies associated with this tab's cookie store. Only present if the extension has the <code>"cookies"</code> <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>.</dd> + <dt><code>discarded</code> {{optional_inline}}</dt> + <dd><code>boolean</code>. タブが破棄されたか。 A discarded tab is one whose content has been unloaded from memory, but is still visible in the tab strip. Its content gets reloaded the next time it's activated.</dd> + <dt><code>favIconUrl</code> {{optional_inline}}</dt> + <dd><code>string</code>. タブのfaviconのURL。Only present if the extension has the <code>"tabs"</code> <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>. It may also be an empty string if the tab is loading.</dd> + <dt><code>height</code> {{optional_inline}}</dt> + <dd><code>integer</code>. タブの高さのピクセル値。</dd> + <dt><code>hidden</code></dt> + <dd><code>boolean</code>. タブが隠されている(非表示)かどうか。</dd> + <dt><code>highlighted</code></dt> + <dd> + <p><code>boolean</code>. タブがハイライトされているかどうかどうか。 An active tab is always highlighted, but some browsers may allow additional tabs to be highlighted, for example by clicking them while holding <kbd>Ctrl</kbd> or <kbd>⌘ Command</kbd> keys.</p> + + <p>Firefox for Android doesn't support highlighting multiple tabs, and Firefox desktop requires the <code>browser.tabs.multiselect</code> preference.</p> + </dd> + <dt><code>id</code> {{optional_inline}}</dt> + <dd><code>integer</code>. タブのID。 タブのIDはブラウザセッショの中でユニークです。The tab ID may also be set to {{WebExtAPIRef('tabs.TAB_ID_NONE')}} for browser windows that don't host content tabs (for example, devtools windows).</dd> + <dt><code>incognito</code></dt> + <dd><code>boolean</code>. タブがプライベートブラウジングウィンドウの中にあるかどうか。</dd> + <dt><code>index</code></dt> + <dd><code>integer</code>. 0を底としたウィンドウの中のタブのインデックス。</dd> + <dt><code>isArticle</code></dt> + <dd><code>boolean</code>. Trueなら<a href="/en-US/Add-ons/WebExtensions/API/tabs/toggleReaderMode">rendered in Reader Mode</a>で閲覧可能、falseならそれ以外。</dd> + <dt><code>isInReaderMode</code></dt> + <dd><code>boolean</code>. Trueなら<a href="/en-US/Add-ons/WebExtensions/API/tabs/toggleReaderMode">rendered in Reader Mode</a>で閲覧中、falseならそれ以外。</dd> + <dt><code>lastAccessed</code></dt> + <dd><code>double</code>. タブが最後にアクセスされた時刻(単位: <a class="external external-icon" href="https://en.wikipedia.org/wiki/Unix_time">milliseconds since the epoch</a>)。</dd> + <dt><code>mutedInfo</code> {{optional_inline}}</dt> + <dd>{{WebExtAPIRef('tabs.MutedInfo')}}. The current muted state for the tab and the reason for the last state change.</dd> + <dt><code>openerTabId</code> {{optional_inline}}</dt> + <dd><code>integer</code>. The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists.</dd> + <dt><code>pinned</code></dt> + <dd><code>boolean</code>. タブがピン留めされているかどうか。</dd> + <dt><code>selected</code> {{deprecated_inline}}</dt> + <dd><code>boolean</code>. タブが選択されているかどうか。</dd> + <dt><code>sessionId</code> {{optional_inline}}</dt> + <dd><code>string</code>. The session ID used to uniquely identify a <code>Tab</code> obtained from the {{WebExtAPIRef('sessions')}} API.</dd> + <dt><code>status</code> {{optional_inline}}</dt> + <dd><code>string</code>. <em>loading</em> か <em>complete</em> のどちらか。</dd> + <dt><code>successorId</code> {{optional_inline}}</dt> + <dd><code>integer</code> タブの後継者のID。</dd> + <dt><code>title</code> {{optional_inline}}</dt> + <dd><code>string</code>. タブのタイトル。Only present if the extension has the <code>"tabs"</code> <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>.</dd> + <dt><code>url</code> {{optional_inline}}</dt> + <dd><code>string</code>. タブが表示しているドキュメントのURL。Only present if the extension has the <code>"tabs"</code> <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>.</dd> + <dt><code>width</code> {{optional_inline}}</dt> + <dd><code>integer</code>. タブの横幅のピクセル値。</dd> + <dt><code>windowId</code></dt> + <dd><code>integer</code>. このタブのホストのウィンドウのID。</dd> + <dt> + <div class="blockIndicator note"> + <p>Note: In extension background scripts, the only properties that are available are tabId and <strong>windowId.</strong></p> + </div> + </dt> +</dl> + +<h2 id="Browser_compatibility">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.api.tabs.Tab", 10)}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs#type-Tab"><code>chrome.tabs</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p> + +<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> |