diff options
Diffstat (limited to 'files/ja/mozilla/add-ons/webextensions/api/bookmarks')
25 files changed, 2730 insertions, 0 deletions
diff --git a/files/ja/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenode/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenode/index.html new file mode 100644 index 0000000000..a6db52f663 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenode/index.html @@ -0,0 +1,91 @@ +--- +title: bookmarks.BookmarkTreeNode +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/BookmarkTreeNode +tags: + - API + - Add-ons + - BookmarkTreeNode + - Bookmarks + - Extensions + - Non-standard + - Reference + - Type + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/BookmarkTreeNode +--- +<div>{{AddonSidebar()}}</div> + +<p><code>bookmarks.BookmarkTreeNode</code> 型のオブジェクトは、ブックマークツリー上のノード(ブックマーク / フォルダ)を表現するものです。子ノードは親フォルダの中で <code>index</code> に従って順序付けされます。</p> + +<h2 id="値の型">値の型</h2> + +<p>以下のプロパティを含む {{jsxref("object")}} です。</p> + +<dl class="reference-values"> + <dt><code>id</code></dt> + <dd>そのノードを一意に識別する {{jsxref("string")}} です。この ID はユーザのプロファイル内で固有であり、ブラウザを再起動した後も有効です。</dd> + <dt><code>parentId </code>{{optional_inline}}</dt> + <dd>親フォルダの ID を表す {{jsxref("string")}} です。ルートノードの場合は省略されます。</dd> + <dt><code>index </code>{{optional_inline}}</dt> + <dd>親フォルダの中におけるノードの位置を表す 0 以上の {{jsxref("number")}} です。0 は先頭の要素を意味します。</dd> + <dt><code>url </code>{{optional_inline}}</dt> + <dd>ブックマークの URL を表す {{jsxref("string")}} です。フォルダの場合は省略されます。</dd> + <dt><code>title</code></dt> + <dd>ブックマークリストやメニューにノードが表示される際のテキストを表す {{jsxref("string")}} です。</dd> + <dt><code>dateAdded</code> {{optional_inline}}</dt> + <dd>このノードが生成された時刻を <a href="https://ja.wikipedia.org/wiki/UNIX%E6%99%82%E9%96%93">1970 年 1 月 1 日からの経過ミリ秒</a> で表す {{jsxref("number")}} です。</dd> + <dt><code>dateGroupModified</code> {{optional_inline}}</dt> + <dd>その内容の最終変更時刻を <a href="https://ja.wikipedia.org/wiki/UNIX%E6%99%82%E9%96%93">1970 年 1 月 1 日からの経過ミリ秒</a> で表す {{jsxref("number")}} です。</dd> + <dt><code>unmodifiable</code> {{optional_inline}}</dt> + <dd>{{WebExtAPIRef('bookmarks.BookmarkTreeNodeUnmodifiable')}} 型で表現される {{jsxref("string")}} です。このノードが変更不可である理由を表します。変更可能な場合には省略されます。</dd> + <dt><code>children</code> {{optional_inline}}</dt> + <dd>各要素がノードの子要素を表す、{{WebExtAPIRef('bookmarks.BookmarkTreeNode')}} の {{jsxref("array")}} です。リストの要素は UI に表示されているのと同じ順序で並びます。フォルダの場合は省略されます。</dd> +</dl> + +<div class="note"> +<p>現在、ブックマークリストのセパレータをこのオブジェクトで表すことはできません。</p> +</div> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.BookmarkTreeNode", 10)}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/bookmarktreenodetype/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenodetype/index.html new file mode 100644 index 0000000000..8a87f614ea --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenodetype/index.html @@ -0,0 +1,39 @@ +--- +title: bookmarks.BookmarkTreeNodeType +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/BookmarkTreeNodeType +tags: + - API + - Add-ons + - BookmarkTreeNodeType + - Bookmarks + - Extensions + - Property + - Reference + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/BookmarkTreeNodeType +--- +<div>{{AddonSidebar()}}</div> + +<p><strong><code>bookmarks.BookmarkTreeNodeType</code></strong> 型は、ブックマークツリーのノードがブックマーク、フォルダーまたはセパレーターであるかどうかを示すために使用されます。</p> + +<h2 id="Type" name="Type">型</h2> + +<p><code>bookmarks.BookmarkTreeNodeType</code> は以下の 3 つのうちいずれかの値を取りうる {{jsxref("string")}} です。</p> + +<ul> + <li><code>"bookmark"</code>: ノードがブックマークであることを示します。</li> + <li><code>"folder"</code>: ノードがフォルダーであることを示します。</li> + <li><code>"separator"</code>: ノードがセパレータであることを示します。</li> +</ul> + +<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.api.bookmarks.BookmarkTreeNodeType", 10)}}</p> + +<div class="hidden"> +<p>NEEDFIX: "WebExtExamples" マクロでエラーがでているため確認と修正が必要</p> +</div> + +<p>{{WebExtExamples}}</p> diff --git a/files/ja/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenodeunmodifiable/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenodeunmodifiable/index.html new file mode 100644 index 0000000000..2d8575e341 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenodeunmodifiable/index.html @@ -0,0 +1,74 @@ +--- +title: bookmarks.BookmarkTreeNodeUnmodifiable +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/BookmarkTreeNodeUnmodifiable +tags: + - API + - Add-ons + - BookmarkTreeNodeUnmodifiable + - Bookmarks + - Extensions + - Non-standard + - Reference + - Type + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/BookmarkTreeNodeUnmodifiable +--- +<p>{{AddonSidebar()}}</p> + +<p><strong><code>bookmarks.BookmarkTreeNodeUnmodifiable</code></strong> 型は、ブックマークツリー上のノード(ブックマーク / フォルダー)が変更不可な理由を表すものです。この型は、ブックマークノードの {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "bookmarks.BookmarkTreeNode.unmodifiable", "unmodifiable")}} プロパティで使用されます。</p> + +<h2 id="Type" name="Type">値の型</h2> + +<p>この値は {{jsxref("string")}} 型であり、現在取りうる値は <code>"managed"</code> のみです。すなわち、システム管理者(ペアレンタルコントロールが有効な場合は保護者)がこのブックマークノードを設定したことを意味します。</p> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザー実装状況</h2> + +<div class="hidden"> +<p>NEEDFIX: "WebExtBrowserCompat" マクロでエラーがでているため確認と修正が必要</p> + +<p>NEEDFIX: "WebExtExamples" マクロでエラーがでているため確認と修正が必要</p> +</div> + +<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.bookmarks.BookmarkTreeNodeUnmodifiable")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a class="external external-icon" href="https://developer.chrome.com/extensions/bookmarks#method-update" rel="noopener"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a class="external external-icon" href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json" rel="noopener"><code>bookmarks.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/bookmarks/create/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/create/index.html new file mode 100644 index 0000000000..1e4a2c36fe --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/create/index.html @@ -0,0 +1,98 @@ +--- +title: bookmarks.create() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/create +tags: + - API + - Add-ons + - Bookmarks + - Create + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/create +--- +<div>{{AddonSidebar()}}</div> + +<p><strong><code>bookmarks.create()</code></strong> は、<code>parentId</code> で指定した {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}} の配下に、ブックマークやフォルダを作成するメソッドです。フォルダを作成する場合は、{{WebExtAPIRef("bookmarks.CreateDetails", "CreateDetails", "url")}} の引数を省略するか空にします。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.create( + bookmark, // CreateDetails + callback // 関数(省略可) +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>bookmark</code></dt> + <dd>{{WebExtAPIRef('bookmarks.CreateDetails')}}</dd> + <dt><code>callback</code>{{optional_inline}}</dt> + <dd>ブックマークが新しく作成された際に呼び出される {{jsxref("function")}} です。この関数は以下の引数を 1 つ受け取ります。</dd> + <dd> + <dl class="reference-values"> + <dt><code>result</code></dt> + <dd>新しく作成されたブックマークノードを表す {{WebExtAPIRef('bookmarks.BookmarkTreeNode')}}</dd> + </dl> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.create")}}</p> + +<h2 id="使用例">使用例</h2> + +<p>以下の例は、このページのブックマークをデフォルトのフォルダ(Firefox は「未分類のブックマーク」、Chrome は「その他のブックマーク」)に作成するものです。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">onBookmarkAdded</span><span class="punctuation token">(</span>bookmarkItem<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Bookmark added with ID: "</span> <span class="operator token">+</span> bookmarkItem<span class="punctuation token">.</span>id<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">create</span><span class="punctuation token">(</span><span class="punctuation token">{</span> + title<span class="punctuation token">:</span> <span class="string token">"bookmarks.create() on MDN"</span><span class="punctuation token">,</span> + url<span class="punctuation token">:</span> <span class="string token">"https://developer.mozilla.org/Add-ons/WebExtensions/API/bookmarks/create"</span> +<span class="punctuation token">}</span><span class="punctuation token">,</span> onBookmarkAdded<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-create"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/createdetails/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/createdetails/index.html new file mode 100644 index 0000000000..b7463079da --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/createdetails/index.html @@ -0,0 +1,81 @@ +--- +title: bookmarks.CreateDetails +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/CreateDetails +tags: + - API + - Add-ons + - Bookmarks + - CreateDetails + - Extensions + - Non-standard + - Reference + - Type + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/CreateDetails +--- +<p>{{AddonSidebar()}}</p> + +<p><code>CreateDetails</code> 型は、新しいブックマークやフォルダのプロパティを表すためのオブジェクト型です。{{WebExtAPIRef("bookmarks.create()")}} メソッドの呼び出し時に渡します。</p> + +<div class="note"> +<p>現在、ブックマークリストのセパレータをこのオブジェクト型で表すことはできません。</p> +</div> + +<h2 id="値の型">値の型</h2> + +<p>以下のプロパティを含む {{jsxref("object")}} です。</p> + +<dl class="reference-values"> + <dt><code>parentId</code>{{optional_inline}}</dt> + <dd>新しいブックマーク / フォルダの親フォルダを指定する {{jsxref("string")}} です。デフォルト値はブラウザによって異なり、Chrome の場合は「その他のブックマーク」、Firefox の場合は「未分類のブックマーク」です。</dd> + <dt><code>index</code>{{optional_inline}}</dt> + <dd>親要素の配下における、新しいブックマーク / フォルダの位置を指定する {{jsxref("number")}} です。値が 0 の場合、リストの先頭に置かれます。</dd> + <dt><code>title</code>{{optional_inline}}</dt> + <dd><code>作成する</code>ブックマークのタイトルやフォルダの名前を指定する {{jsxref("string")}} です。値を省略した場合、タイトルは <code>""</code> になります。</dd> + <dt><code>url</code>{{optional_inline}}</dt> + <dd>ブックマークの URL を指定する {{jsxref("string")}} です。値を省略するか <code>null</code> を指定した場合、ブックマークではなくフォルダが作成されます。</dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.CreateDetails", 10)}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/export/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/export/index.html new file mode 100644 index 0000000000..381e471807 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/export/index.html @@ -0,0 +1,114 @@ +--- +title: bookmarks.export() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/export +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - export +translation_of: Archive/Add-ons/bookmarks.export +--- +<p>{{AddonSidebar()}}</p> + +<p>ブックマークを HTML ブックマークファイルにエクスポートします。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.export( + function() {...} // 関数(省略可) +) +</pre> + +<h3 id="Parameters">Parameters</h3> + +<dl> + <dt><code>callback</code>{{optional_inline}}</dt> + <dd><code>function</code>.</dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{ CompatibilityTable() }}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>機能</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Opera</th> + </tr> + <tr> + <td>基本サポート</td> + <td>{{ CompatVersionUnknown }}</td> + <td>{{ CompatUnknown }}</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatOpera('33') }}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>機能</th> + <th>Edge</th> + <th>Firefox OS</th> + <th>Firefox Mobile (Gecko)</th> + </tr> + <tr> + <td>基本サポート</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatNo() }}</td> + </tr> + </tbody> +</table> +</div> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/get/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/get/index.html new file mode 100644 index 0000000000..a3d5245abc --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/get/index.html @@ -0,0 +1,102 @@ +--- +title: bookmarks.get() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/get +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - get +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/get +--- +<div>{{AddonSidebar()}}</div> + +<p><strong><code>bookmarks.get()</code></strong> は、指定した {{WebExtAPIRef("bookmarks.BookmarkTreeNode")}} の ID(または ID の配列)にマッチするノードを取得するメソッドです。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.get( + idOrIdList, // 文字列または文字列の配列 + callback // 関数 +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>idOrIdList</code></dt> + <dd>取得したい {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}} オブジェクトの ID を指定した {{jsxref("string")}} または {{jsxref("string")}} の {[jsxref("array")}} です。</dd> + <dt><code>callback</code></dt> + <dd>ノードが取得された際に実行される {{jsxref("function")}} です。この関数には以下の引数が渡ります。</dd> + <dd> + <dl class="reference-values"> + <dt><code>results</code></dt> + <dd>各要素が {{WebExtAPIRef("bookmarks.BookmarkTreeNode")}} である、マッチしたノードの {{jsxref("array")}} です。セパレータは結果の戻り値に含まれません。ノードが見つからなかった場合の <code>results</code> は <code>undefined</code> となり、{{WebExtAPIRef("runtime.lastError")}} がセットされます。</dd> + </dl> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.get")}}</p> + +<h2 id="使用例">使用例</h2> + +<p>以下の例は、特定の ID を持つブックマークが存在するかどうかを確認するものです。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">onGot</span><span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"bookmark exists!"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> <span class="keyword token">else</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"bookmark does not exist!"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"lasterror: "</span> <span class="operator token">+</span> chrome<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span>lastError<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">doesBookmarkExist</span><span class="punctuation token">(</span>bookmarkId<span class="punctuation token">)</span> <span class="punctuation token">{</span> + browser<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="keyword token">get</span><span class="punctuation token">(</span>bookmarkId<span class="punctuation token">,</span> onGot<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-get"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/getchildren/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/getchildren/index.html new file mode 100644 index 0000000000..6a489247c5 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/getchildren/index.html @@ -0,0 +1,126 @@ +--- +title: bookmarks.getChildren() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/getChildren +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - getChildren +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/getChildren +--- +<p>{{AddonSidebar()}}</p> + +<p><strong><code>bookmarks.getChildren()</code></strong> は、ブックマークフォルダの ID を {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}} で指定し、その直下にあたる子要素をすべて取得します。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.getChildren( + id, // 文字列 + callback // 関数 +) +</pre> + +<h3 id="Parameters">Parameters</h3> + +<dl> + <dt><code>id</code></dt> + <dd>取得したい子要素を持つフォルダ ID を指定する {{jsxref("string")}} です。</dd> + <dt><code>callback</code></dt> + <dd>子ノードのリストが取得された際に実行される関数です。この関数には以下の引数が渡ります。</dd> + <dd> + <dl class="reference-values"> + <dt><code>results</code></dt> + <dd>各要素が 1 つの子ノードを表す、{{WebExtAPIRef('bookmarks.BookmarkTreeNode')}} の {{jsxref("array")}} です。要素の順序は、UI に表示されているのと同じ順番です。現在、セパレータの有無は結果に含まれません。指定したノードに子要素が含まれていなかった場合、<code>results</code> は空配列となります。</dd> + </dl> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.getChildren")}}</p> + +<h2 id="使用例">使用例</h2> + +<h3 id="基本的な使い方">基本的な使い方</h3> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">gotChildren</span><span class="punctuation token">(</span>children<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>children<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">getChildren</span><span class="punctuation token">(</span>bookmarkItemId<span class="punctuation token">,</span> gotChildren<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<h3 id="指定したフォルダでブックマークを切替">指定したフォルダでブックマークを切替</h3> + +<p>以下の例は、フォルダを {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}} で指定し、そのフォルダに新しいブックマークを作成するものです。ただし、既に同じ名前のブックマークがあった場合は、逆に既存のブックマークを削除することとします。このとき新しいブックマークは作成されません。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">toggleBookmark</span><span class="punctuation token">(</span>folderNode<span class="punctuation token">,</span> title<span class="punctuation token">,</span> url<span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">getChildren</span><span class="punctuation token">(</span>folderNode<span class="punctuation token">.</span>id<span class="punctuation token">,</span> <span class="keyword token">function</span><span class="punctuation token">(</span>results<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">let</span> node <span class="operator token">=</span> results<span class="punctuation token">.</span><span class="function token">find</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span>el<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">return</span> el<span class="punctuation token">.</span>title <span class="operator token">===</span> title<span class="punctuation token">;</span> + <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + + <span class="comment token">// ブックマークが存在する場合は削除する</span> + <span class="comment token">// そうでなければ新しく作成する</span> + + <span class="keyword token">if</span> <span class="punctuation token">(</span>node <span class="operator token">!==</span> undefined<span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">remove</span><span class="punctuation token">(</span>node<span class="punctuation token">.</span>id<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> <span class="keyword token">else</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">create</span><span class="punctuation token">(</span><span class="punctuation token">{</span> + parentId<span class="punctuation token">:</span> folderNode<span class="punctuation token">.</span>id<span class="punctuation token">,</span> + title<span class="punctuation token">:</span> title<span class="punctuation token">,</span> + url<span class="punctuation token">:</span> url + <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> + <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span></code></pre> + +<p>先の <code>toggleBookmark()</code> 関数は、<code>folderNode</code> で指定した {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}} の中に既に存在しているすべてのブックマークのリストを取得するため、最初に <code>bookmarks.getChildren()</code> を呼び出しています。</p> + +<p>コールバックに指定された匿名関数には <code>results</code> という引数が 1 つ渡されます。この引数は、フォルダの直下にある子要素をすべて含んだ配列です。まず初めに、与えられたタイトルを持つノードがフォルダに存在するかどうかを調べます。ここでは {{jsxref("Array.find()")}} メソッドを使い、タイトルが等しいかどうかをコールバック内で判定しています。</p> + +<p>マッチするノードがあった場合(すなわち、<code>node</code> が <code>undefined</code> ではない場合)、指定した <code>title</code> を持つブックマークが既に存在していたことが分かったので、既存のブックマークを削除するために {{WebExtAPIRef("bookmarks.remove()")}} を呼び出します。</p> + +<p>そうではなかった場合、新しいブックマークを作成するために {{WebExtAPIRef("bookmarks.create()")}} が呼び出します。この際、引数 <code>folderNode</code> で与えられていたフォルダ ID を新しい親フォルダの ID に指定し、合わせて <code>title</code> と <code>url</code> も指定します。</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-getChildren"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/getrecent/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/getrecent/index.html new file mode 100644 index 0000000000..3900d1888f --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/getrecent/index.html @@ -0,0 +1,97 @@ +--- +title: bookmarks.getRecent() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/getRecent +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - getRecent +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/getRecent +--- +<p>{{AddonSidebar()}}</p> + +<p><strong><code>bookmarks.getRecent()</code></strong> は、最近に追加されたブックマークを指定した最大個数まで取得し、{{WebExtAPIRef('bookmarks.BookmarkTreeNode', 'BookmarkTreeNode')}} オブジェクトの配列としてコールバック関数に渡します。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.getRecent( + numberOfItems, // 整数 + callback // 関数 +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>numberOfItems</code></dt> + <dd>取得する要素の最大個数を指定する整数です。最近追加された要素のうち、ここで指定した個数までが戻り値のリストに含まれます。</dd> + <dt><code>callback</code></dt> + <dd>リストが取得された際に実行される関数です。この関数には以下の引数が渡ります。</dd> + <dd> + <dl class="reference-values"> + <dt><code>results</code></dt> + <dd>各要素が 1 つのブックマークノードを表す {{WebExtAPIRef('bookmarks.BookmarkTreeNode')}} オブジェクトの {{jsxref("array")}}</dd> + </dl> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.getRecent")}}</p> + +<h2 id="使用例">使用例</h2> + +<p id="Find_the_most_recently_added_bookmark">以下の例は、直近に追加されたブックマークの URL を出力するものです。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">gotMostRecent</span><span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">.</span>length<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">[</span><span class="number token">0</span><span class="punctuation token">]</span><span class="punctuation token">.</span>url<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">getRecent</span><span class="punctuation token">(</span><span class="number token">1</span><span class="punctuation token">,</span> gotMostRecent<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-getRecent"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/getsubtree/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/getsubtree/index.html new file mode 100644 index 0000000000..c13185cd5a --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/getsubtree/index.html @@ -0,0 +1,125 @@ +--- +title: bookmarks.getSubTree() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/getSubTree +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - getSubTree +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/getSubTree +--- +<p>{{AddonSidebar()}}</p> + +<p><strong><code>bookmarks.getSubTree()</code></strong> は、ID を指定して {{WebExtAPIRef("bookmarks.BookmarkTreeNode")}} を非同期に取得するメソッドです。</p> + +<p>対象がフォルダの場合、<code>children</code> プロパティを再帰的にたどることで、すべての子要素にアクセスすることができます。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.getSubTree( + id, // 文字列 + callback // 関数 +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>id</code></dt> + <dd>取得したい部分木のルートノードに対応する ID を表す {{jsxref("string")}} です。</dd> + <dt><code>callback</code></dt> + <dd>リクエストしたノードが取得された際に呼び出される関数です。この関数には以下の引数が渡ります。</dd> + <dd> + <dl class="reference-values"> + <dt><code>results</code></dt> + <dd>指定した ID に対応する {{WebExtAPIRef('bookmarks.BookmarkTreeNode')}} オブジェクトが 1 つ含まれた配列</dd> + </dl> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.getSubTree")}}</p> + +<h2 id="例">例</h2> + +<p>以下の例は、指定したノードの配下にある部分木を再帰的に出力するものです。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">makeIndent</span><span class="punctuation token">(</span>indentLength<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">return</span> <span class="string token">"."</span><span class="punctuation token">.</span><span class="function token">repeat</span><span class="punctuation token">(</span>indentLength<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">logItems</span><span class="punctuation token">(</span>bookmarkItem<span class="punctuation token">,</span> indent<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span>bookmarkItem<span class="punctuation token">.</span>url<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="function token">makeIndent</span><span class="punctuation token">(</span>indent<span class="punctuation token">)</span> <span class="operator token">+</span> bookmarkItem<span class="punctuation token">.</span>url<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> <span class="keyword token">else</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="function token">makeIndent</span><span class="punctuation token">(</span>indent<span class="punctuation token">)</span> <span class="operator token">+</span> <span class="string token">"Folder"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + indent<span class="operator token">++</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span>bookmarkItem<span class="punctuation token">.</span>children<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">for</span> <span class="punctuation token">(</span>child <span class="keyword token">of</span> bookmarkItem<span class="punctuation token">.</span>children<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="function token">logItems</span><span class="punctuation token">(</span>child<span class="punctuation token">,</span> indent<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> + <span class="punctuation token">}</span> + indent<span class="operator token">--</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">logSubTree</span><span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="function token">logItems</span><span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">[</span><span class="number token">0</span><span class="punctuation token">]</span><span class="punctuation token">,</span> <span class="number token">0</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">handleClick</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">var</span> subTreeID <span class="operator token">=</span> <span class="string token">"unfiled_____"</span><span class="punctuation token">;</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">getSubTree</span><span class="punctuation token">(</span>subTreeID<span class="punctuation token">,</span> logSubTree<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleClick<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a class="external external-icon" href="https://developer.chrome.com/extensions/bookmarks#method-getSubTree"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a class="external external-icon" href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.json</code></a> における Chromium のコードから作成されています。</p> + +<p>Microsoft Edge の実装状況は Microsoft Corporation から提供されたものであり、ここでは Creative Commons Attribution 3.0 United States License に従います。</p> +</div> + +<p> </p> + +<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> + +<p> </p> diff --git a/files/ja/mozilla/add-ons/webextensions/api/bookmarks/gettree/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/gettree/index.html new file mode 100644 index 0000000000..b66987075d --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/gettree/index.html @@ -0,0 +1,117 @@ +--- +title: bookmarks.getTree() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/getTree +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - getTree +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/getTree +--- +<p>{{AddonSidebar()}}</p> + +<p><strong><code>bookmarks.getTree()</code></strong> は、ブックマークツリーのルートを表した{{WebExtAPIRef("bookmarks.BookmarkTreeNode")}} オブジェクトの配列を返します。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.getTree( + callback // 関数 +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>callback</code></dt> + <dd>ルートに相当するノードが取得された際に実行される関数です。この関数には以下の引数が渡ります。</dd> + <dd> + <dl class="reference-values"> + <dt><code>results</code></dt> + <dd> + <p>ルートノードを表す {{WebExtAPIRef('bookmarks.BookmarkTreeNode')}} オブジェクトが 1 つ含まれた配列</p> + </dd> + </dl> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.getTree")}}</p> + +<h2 id="例">例</h2> + +<p>以下の例は、ブックマークツリー全体を出力するものです。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">makeIndent</span><span class="punctuation token">(</span>indentLength<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">return</span> <span class="string token">"."</span><span class="punctuation token">.</span><span class="function token">repeat</span><span class="punctuation token">(</span>indentLength<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">logItems</span><span class="punctuation token">(</span>bookmarkItem<span class="punctuation token">,</span> indent<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span>bookmarkItem<span class="punctuation token">.</span>url<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="function token">makeIndent</span><span class="punctuation token">(</span>indent<span class="punctuation token">)</span> <span class="operator token">+</span> bookmarkItem<span class="punctuation token">.</span>url<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> <span class="keyword token">else</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="function token">makeIndent</span><span class="punctuation token">(</span>indent<span class="punctuation token">)</span> <span class="operator token">+</span> <span class="string token">"Folder"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + indent<span class="operator token">++</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span>bookmarkItem<span class="punctuation token">.</span>children<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">for</span> <span class="punctuation token">(</span>child <span class="keyword token">of</span> bookmarkItem<span class="punctuation token">.</span>children<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="function token">logItems</span><span class="punctuation token">(</span>child<span class="punctuation token">,</span> indent<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> + <span class="punctuation token">}</span> + indent<span class="operator token">--</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">logTree</span><span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="function token">logItems</span><span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">[</span><span class="number token">0</span><span class="punctuation token">]</span><span class="punctuation token">,</span> <span class="number token">0</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">handleClick</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">getTree</span><span class="punctuation token">(</span>logTree<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleClick<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>この API は Chromium の <a class="external external-icon" href="https://developer.chrome.com/extensions/bookmarks#method-getTree"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a class="external external-icon" href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/import/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/import/index.html new file mode 100644 index 0000000000..758b72dbfa --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/import/index.html @@ -0,0 +1,114 @@ +--- +title: bookmarks.import() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/import +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - import +translation_of: Archive/Add-ons/bookmarks.import +--- +<p>{{AddonSidebar()}}</p> + +<p>ブックマークを HTML ブックマークファイルからインポートします。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.import( + function() {...} // 関数(省略可) +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>callback</code>{{optional_inline}}</dt> + <dd><code>function</code>.</dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{ CompatibilityTable() }}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>機能</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Opera</th> + </tr> + <tr> + <td>基本サポート</td> + <td>{{ CompatVersionUnknown }}</td> + <td>{{ CompatUnknown }}</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatOpera('33') }}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>機能</th> + <th>Edge</th> + <th>Firefox OS</th> + <th>Firefox Mobile (Gecko)</th> + </tr> + <tr> + <td>基本サポート</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatNo() }}</td> + </tr> + </tbody> +</table> +</div> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/index.html new file mode 100644 index 0000000000..c1c073c551 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/index.html @@ -0,0 +1,130 @@ +--- +title: bookmarks +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Interface + - Non-standard + - Reference + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks +--- +<p>{{AddonSidebar}}</p> + +<p><a href="https://developer.mozilla.org/ja/docs/Mozilla/Add-ons/WebExtensions">WebExtensions</a> {{WebExtAPIRef("bookmarks")}} API を利用すると、拡張機能からブラウザーのブックマークシステムにアクセスしたり、操作することができます。ページをブックマークしたり、既存のブックマークを取得したり、ブックマークを編集・削除・整理することが可能です。</p> + +<p>この API を使用する際は、拡張機能の <code><a href="https://developer.mozilla.org/ja/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a></code> ファイルで "bookmarks" <a href="/ja/Add-ons/WebExtensions/manifest.json/permissions">パーミッション</a> を指定する必要があります。</p> + +<p>拡張機能ではブックマークツリーのルートノードではブックマークを作成・編集・削除できません。それをしようとすると次のエラーになります: "<em>The bookmark root cannot be modified</em>"</p> + +<h2 id="Types" name="Types">関連する値の型</h2> + +<dl> + <dt>{{WebExtAPIRef("bookmarks.BookmarkTreeNode")}}</dt> + <dd>ブックマークツリー上のブックマークやフォルダーを表します。</dd> + <dt>{{WebExtAPIRef("bookmarks.BookmarkTreeNodeType")}}</dt> + <dd>ツリー内のノードがブックマークかフォルダーかセパレーターかを表す {{jsxref("string")}} の列挙型です。</dd> + <dt>{{WebExtAPIRef("bookmarks.BookmarkTreeNodeUnmodifiable")}}</dt> + <dd>ブックマークやフォルダーが変更不可である理由を表す {{jsxref("string")}} の列挙型です。</dd> + <dt>{{WebExtAPIRef("bookmarks.CreateDetails")}}</dt> + <dd>新しいブックマークを作成する際、{{WebExtAPIRef("bookmarks.create()")}} メソッドに渡す情報を含みます。</dd> +</dl> + +<h2 id="Functions" name="Functions">関数</h2> + +<dl> + <dt>{{WebExtAPIRef("bookmarks.create()")}}</dt> + <dd>ブックマークやフォルダーを作成します。</dd> + <dt>{{WebExtAPIRef("bookmarks.get()")}}</dt> + <dd>ブックマークの ID や ID の配列を指定し、1 つ以上の {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode(s)")}} を取得します。</dd> + <dt>{{WebExtAPIRef("bookmarks.getChildren()")}}</dt> + <dd>指定した {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}} の子要素を取得します。</dd> + <dt>{{WebExtAPIRef("bookmarks.getRecent()")}}</dt> + <dd>最近追加されたブックマークを取得します。</dd> + <dt>{{WebExtAPIRef("bookmarks.getSubTree()")}}</dt> + <dd>指定したノードを起点とする、ブックマークツリーの部分木を取得します。</dd> + <dt>{{WebExtAPIRef("bookmarks.getTree()")}}</dt> + <dd>ブックマークのツリー全体を {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}} オブジェクトの配列として取得します。</dd> + <dt>{{WebExtAPIRef("bookmarks.move()")}}</dt> + <dd>指定した {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}} を所望の場所に移します。</dd> + <dt>{{WebExtAPIRef("bookmarks.remove()")}}</dt> + <dd>ノードの ID を指定し、ブックマークや空のブックマークフォルダーを削除します。</dd> + <dt>{{WebExtAPIRef("bookmarks.removeTree()")}}</dt> + <dd>ブックマークのフォルダーを再帰的に削除します。すなわち、フォルダーノードの ID を指定し、そのノードと子要素すべてを削除します。</dd> + <dt>{{WebExtAPIRef("bookmarks.search()")}}</dt> + <dd>与えた条件に一致する {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNodes")}} を検索します。</dd> + <dt>{{WebExtAPIRef("bookmarks.update()")}}</dt> + <dd>ブックマークの ID を指定し、ブックマークの URL やタイトル、またはフォルダーの名前を更新します。</dd> +</dl> + +<h2 id="Events" name="Events">Events</h2> + +<dl> + <dt>{{WebExtAPIRef("bookmarks.onCreated")}}</dt> + <dd>ブックマークやフォルダーが作成された際に発火します。</dd> + <dt>{{WebExtAPIRef("bookmarks.onRemoved")}}</dt> + <dd>ブックマークやフォルダーが削除された際に発火します。フォルダーが再帰的に削除された場合は、そのフォルダーに対して一回だけ発火し、フォルダーの中身については発火しません。</dd> + <dt>{{WebExtAPIRef("bookmarks.onChanged")}}</dt> + <dd>ブックマークやフォルダーが変更された際に発火します。現在は <code>title</code> と url の変更に対してのみ発火します。</dd> + <dt>{{WebExtAPIRef("bookmarks.onMoved")}}</dt> + <dd>異なる親フォルダーへ、または同じフォルダー内の異なる場所へブックマークやフォルダーが移された際に発火します。</dd> + <dt>{{WebExtAPIRef("bookmarks.onChildrenReordered")}}</dt> + <dd>UI で表示されている順序に伴って子フォルダーの順序も変更された際に発火します。{{WebExtAPIRef("bookmarks.move", "move()")}} の実行後には発火しません。</dd> + <dt>{{WebExtAPIRef("bookmarks.onImportBegan")}}</dt> + <dd>ブックマークのインポートが開始した際に発火します。パフォーマンスが重要である場合、イベントのオブザーバは {{WebExtAPIRef("bookmarks.onImportEnded")}} が発火するまで {{WebExtAPIRef("bookmarks.onCreated")}} を無視すべきでしょう。その場合であっても、オブザーバは他のイベントについては即座に処理すべきでしょう。</dd> + <dt>{{WebExtAPIRef("bookmarks.onImportEnded")}}</dt> + <dd>ブックマークのインポートが終了した際に発火します。</dd> +</dl> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザー実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks")}}</p> + +<div class="hidden note"> +<p>The "Chrome incompatibilities" section is included from <a href="https://developer.mozilla.org/ja/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/ja/Add-ons/WebExtensions/Chrome_incompatibilities</a> using the <a href="/ja/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p> + +<p>If you need to update this content, edit <a href="https://developer.mozilla.org/ja/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/ja/Add-ons/WebExtensions/Chrome_incompatibilities</a>, then shift-refresh this page to see your changes.</p> +</div> + +<p>{{WebExtExamples("h2")}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/move/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/move/index.html new file mode 100644 index 0000000000..c164626551 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/move/index.html @@ -0,0 +1,107 @@ +--- +title: bookmarks.move() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/move +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/move +--- +<p>{{AddonSidebar()}}</p> + +<p><strong><code>bookmarks.move()</code></strong> は、指定した {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}} をブックマークツリー内の所望の位置に移すメソッドです。このメソッドにより、ブックマークを新しいフォルダの中や、同じフォルダ内の別の場所に移動させることができます。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.move( + id, // 文字列 + destination, // オブジェクト + callback // 関数(省略可) +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>id</code></dt> + <dd>移動させるブックマーク / フォルダの ID を表す {{jsxref("string")}} です。</dd> + <dt><code>destination</code></dt> + <dd>ブックマークの移動先を表す {{jsxref("object")}} です。このオブジェクトには以下のプロパティが必ず 1 つ以上含まれます。</dd> + <dd> + <dl class="reference-values"> + <dt><code>parentId </code>{{optional_inline}}</dt> + <dd>移動先フォルダの ID を指定する {{jsxref("string")}} です。この値が省略された場合、現在と同じフォルダ内の新しい場所へ移動されます。</dd> + <dt><code>index </code>{{optional_inline}}</dt> + <dd>移動先フォルダ内における位置を指定する 0 起点のインデックスです。値が 0 の場合、そのフォルダの先頭に移動されます。値が省略された場合、新しい親フォルダ内の最後に移動されます。</dd> + </dl> + </dd> + <dt><code>callback </code>{{optional_inline}}</dt> + <dd>移動が終了した際に呼び出される {{jsxref("function")}} です。この関数は以下の引数を 1 つ受け取ります。</dd> + <dd> + <dl class="reference-values"> + <dt><code>result</code></dt> + <dd>移動された新しいノードを表す {{WebExtAPIRef('bookmarks.BookmarkTreeNode', 'BookmarkTreeNode')}}</dd> + </dl> + + <p> </p> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.move")}}</p> + +<h2 id="使用例">使用例</h2> + +<h3 id="ブックマークを現在のフォルダの先頭へ移動">ブックマークを現在のフォルダの先頭へ移動</h3> + +<p>次の例は、既存のブックマークを現在のフォルダの先頭へ移動させるものです。移動後に必要な処理は特にないため、ここではコールバック無しで呼び出しています。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js">browser<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">move</span><span class="punctuation token">(</span>bookmarkID<span class="punctuation token">,</span> <span class="punctuation token">{</span> index<span class="punctuation token">:</span> <span class="number token">0</span> <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<h3 id="ブックマークを異なるフォルダへ移動">ブックマークを異なるフォルダへ移動</h3> + +<p>以下の例は、ID で指定したブックマークを、別の ID で指定したフォルダへ移動させる関数です。今回は、移動後に実行されるコールバック関数も指定しています。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">moveToFolder</span><span class="punctuation token">(</span>bookmarkId<span class="punctuation token">,</span> destinationId<span class="punctuation token">)</span> <span class="punctuation token">{</span> + browser<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">move</span><span class="punctuation token">(</span>bookmarkId<span class="punctuation token">,</span> <span class="punctuation token">{</span> parentId<span class="punctuation token">:</span> destinationId <span class="punctuation token">}</span><span class="punctuation token">,</span> + <span class="keyword token">function</span><span class="punctuation token">(</span>updatedNode<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="comment token">/* ブックマークの移動後に行う処理 */</span> + <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium <code>の </code><a href="https://developer.chrome.com/extensions/bookmarks#method-move"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメント<code>は </code><a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/onchanged/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onchanged/index.html new file mode 100644 index 0000000000..bf6cf83ce7 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onchanged/index.html @@ -0,0 +1,138 @@ +--- +title: bookmarks.onChanged +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/onChanged +tags: + - API + - Add-ons + - Bookmarks + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onChanged +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/onChanged +--- +<div>{{AddonSidebar()}}</div> + +<p>以下の変更に対して発火します。</p> + +<ul> + <li>ブックマークのタイトルまたは URL</li> + <li>フォルダの名前</li> +</ul> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.onChanged.addListener(function( + id, // 文字列 + changeInfo // オブジェクト +) {...}) +browser.bookmarks.onChanged.removeListener(listener) +browser.bookmarks.onChanged.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> + </dd> +</dl> + +<dl> + <dd> + <dl class="reference-values"> + <dt><code>id</code></dt> + <dd>変更を受けた要素の ID を表す {{jsxref("string")}}</dd> + </dl> + + <dl class="reference-values"> + <dt><code>changeInfo</code></dt> + <dd>変更に関する詳細を含んだ {{jsxref("object")}}</dd> + </dl> + </dd> +</dl> + +<h2 id="付随するオブジェクト">付随するオブジェクト</h2> + +<h3 id="changeInfo">changeInfo</h3> + +<dl class="reference-values"> + <dt><code>title</code></dt> + <dd>変更された要素のタイトルを表す {{jsxref("string")}}</dd> + <dt><code>url</code>{{optional_inline}}</dt> + <dd>変更された要素の URL を表す {{jsxref("string")}}。要素がフォルダだった場合に値は入りません。</dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.onChanged")}}</p> + +<h2 id="使用例">使用例</h2> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">handleChanged</span><span class="punctuation token">(</span>id<span class="punctuation token">,</span> changeInfo<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Item: "</span> <span class="operator token">+</span> id <span class="operator token">+</span> <span class="string token">" changed"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Title: "</span> <span class="operator token">+</span> changeInfo<span class="punctuation token">.</span>title<span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Url: "</span> <span class="operator token">+</span> changeInfo<span class="punctuation token">.</span>url<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">handleClick</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span>onChanged<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleChanged<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleClick<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/onchildrenreordered/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onchildrenreordered/index.html new file mode 100644 index 0000000000..3d5b10eb91 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onchildrenreordered/index.html @@ -0,0 +1,130 @@ +--- +title: bookmarks.onChildrenReordered +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/onChildrenReordered +tags: + - API + - Add-ons + - Bookmarks + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onChildrenReordered +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/onChildrenReordered +--- +<p>{{AddonSidebar()}}</p> + +<p>UI で表示されている順序に伴って子フォルダの順序も変更された際に発火します。{{WebExtAPIRef("bookmarks.move()")}} の実行後や、UI におけるドラッグの際には発火しません。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.onChildrenReordered.addListener(function( + id, // 文字列 + reorderInfo // オブジェクト +) {...}) +browser.bookmarks.onChildrenReordered.removeListener(listener) +browser.bookmarks.onChildrenReordered.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> + </dd> +</dl> + +<dl> + <dd> + <dl class="reference-values"> + <dt><code>id</code></dt> + <dd>子要素の順序が変更されたフォルダの ID を表す {{jsxref("string")}} です。</dd> + </dl> + + <dl class="reference-values"> + <dt><code>reorderInfo</code></dt> + <dd>詳細情報を含んだ {{jsxref("object")}} です。</dd> + </dl> + </dd> +</dl> + +<h2 id="付随するオブジェクト">付随するオブジェクト</h2> + +<h3 id="reorderInfo">reorderInfo</h3> + +<dl class="reference-values"> + <dt><code>childIds</code></dt> + <dd>{{jsxref("string")}} の {{jsxref("array")}} です。このフォルダに含まれるブックマーク要素すべての ID が含まれており、UI に表示されているのと同じ順番に並んでいます。</dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.onChildrenReordered")}}</p> + +<h2 id="使用例">使用例</h2> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">handleChildrenReordered</span><span class="punctuation token">(</span>id<span class="punctuation token">,</span> reorderInfo<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Item: "</span> <span class="operator token">+</span> id <span class="operator token">+</span> <span class="string token">" children reordered"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Children: "</span> <span class="operator token">+</span> reorderInfo<span class="punctuation token">.</span>childIds<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">handleClick</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span>onChildrenReordered<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleChildrenReordered<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleClick<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/oncreated/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/oncreated/index.html new file mode 100644 index 0000000000..5c1eea40d5 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/oncreated/index.html @@ -0,0 +1,104 @@ +--- +title: bookmarks.onCreated +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/onCreated +tags: + - API + - Add-ons + - Bookmarks + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onCreated +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/onCreated +--- +<div>{{AddonSidebar()}}</div> + +<p>ブックマークやフォルダが作成された際に発火します。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.onCreated.addListener(function( + id, // 文字列 + bookmark // BookmarkTreeNode +) {...}) +browser.bookmarks.onCreated.removeListener(listener) +browser.bookmarks.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>イベントが発火した際に呼び出される {{jsxref("function")}} です。この関数には以下の引数が渡ります。</p> + + <dl class="reference-values"> + <dt><code>id</code></dt> + <dd><code>string</code>.</dd> + </dl> + + <dl class="reference-values"> + <dt><code>bookmark</code></dt> + <dd>{{WebExtAPIRef('bookmarks.BookmarkTreeNode')}}.</dd> + </dl> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.onCreated")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/onimportbegan/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onimportbegan/index.html new file mode 100644 index 0000000000..6a11683646 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onimportbegan/index.html @@ -0,0 +1,110 @@ +--- +title: bookmarks.onImportBegan +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/onImportBegan +tags: + - API + - Add-ons + - Bookmarks + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onImportBegan +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/onImportBegan +--- +<p>{{AddonSidebar()}}</p> + +<p>ブックマークのインポートが開始した際に発火します。</p> + +<p>ブックマークをインポートしている間、{{WebExtAPIRef("bookmarks.onCreated", "onCreated")}} が何度も発火する場合があります。<code>onCreated</code> に紐づけるリスナ関数の処理が重い場合には、<code>onImportBegan</code> と {{WebExtAPIRef("bookmarks.onImportEnded", "onImportEnded")}} をリッスンし、<code>onImportEnded</code> が発火するまでは <code>onCreated</code> を無視してください。他のイベントは通常通り処理できます。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.onImportBegan.addListener(function() {...}) +browser.bookmarks.onImportBegan.removeListener(listener) +browser.bookmarks.onImportBegan.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> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.onImportBegan")}}</p> + +<h2 id="使用例">使用例</h2> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">handleImportBegan</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Importing..."</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">handleImportEnded</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"...finished."</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">handleClick</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span>onImportBegan<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleImportBegan<span class="punctuation token">)</span><span class="punctuation token">;</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span>onImportEnded<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleImportEnded<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleClick<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/onimportended/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onimportended/index.html new file mode 100644 index 0000000000..4ecfe782cf --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onimportended/index.html @@ -0,0 +1,110 @@ +--- +title: bookmarks.onImportEnded +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/onImportEnded +tags: + - API + - Add-ons + - Bookmarks + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onImportEnded +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/onImportEnded +--- +<p>{{AddonSidebar()}}</p> + +<p>ブックマークのインポートが終了した際に発火します。</p> + +<p>{{WebExtAPIRef("bookmarks.onImportBegan")}} も参照してください。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.onImportEnded.addListener(function() {...}) +browser.bookmarks.onImportEnded.removeListener(listener) +browser.bookmarks.onImportEnded.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> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.onImportEnded")}}</p> + +<h2 id="使用例">使用例</h2> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">handleImportBegan</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Importing..."</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">handleImportEnded</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"...finished."</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">handleClick</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span>onImportBegan<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleImportBegan<span class="punctuation token">)</span><span class="punctuation token">;</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span>onImportEnded<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleImportEnded<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleClick<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/onmoved/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onmoved/index.html new file mode 100644 index 0000000000..6b14db985b --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onmoved/index.html @@ -0,0 +1,139 @@ +--- +title: bookmarks.onMoved +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/onMoved +tags: + - API + - Add-ons + - Bookmarks + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onMoved +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/onMoved +--- +<p>{{AddonSidebar()}}</p> + +<p>ブックマークやフォルダが、異なる親フォルダやフォルダ内の別の場所へ移された際に発火します。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.onMoved.addListener(function( + id, // 文字列 + moveInfo // オブジェクト +) {...}) +browser.bookmarks.onMoved.removeListener(listener) +browser.bookmarks.onMoved.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> + </dd> +</dl> + +<dl> + <dd> + <dl class="reference-values"> + <dt><code>id</code></dt> + <dd>移動した要素の ID を表す {{jsxref("string")}} です。</dd> + </dl> + + <dl class="reference-values"> + <dt><code>moveInfo</code></dt> + <dd>移動に関する詳細を含んだ {{jsxref("object")}} です。</dd> + </dl> + </dd> +</dl> + +<h2 id="付随するオブジェクト">付随するオブジェクト</h2> + +<h3 id="moveInfo">moveInfo</h3> + +<dl class="reference-values"> + <dt><code>parentId</code></dt> + <dd>新しい親フォルダを表す {{jsxref("string")}}</dd> + <dt><code>index</code></dt> + <dd>この要素が親から見て何番目にあるかを表す整数</dd> + <dt><code>oldParentId</code></dt> + <dd>移動前の親フォルダを表す {{jsxref("string")}}</dd> + <dt><code>oldIndex</code></dt> + <dd><code>移動前において、</code>この要素が親から見て何番目にあったかを表す整数</dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.onMoved")}}</p> + +<h2 id="Examples">Examples</h2> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">handleMoved</span><span class="punctuation token">(</span>id<span class="punctuation token">,</span> moveInfo<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Item: "</span> <span class="operator token">+</span> id <span class="operator token">+</span> <span class="string token">" moved"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Old index: "</span> <span class="operator token">+</span> moveInfo<span class="punctuation token">.</span>oldIndex<span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"New index: "</span> <span class="operator token">+</span> moveInfo<span class="punctuation token">.</span>index<span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Old folder: "</span> <span class="operator token">+</span> moveInfo<span class="punctuation token">.</span>oldParentId<span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"New folder: "</span> <span class="operator token">+</span> moveInfo<span class="punctuation token">.</span>parentId<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">handleClick</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span>onMoved<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleMoved<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleClick<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.json</code></a> における Chromium のコードから作成されています。</p> + +<p>Microsoft Edge compatibility の実装状況は 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/bookmarks/onremoved/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onremoved/index.html new file mode 100644 index 0000000000..abe7b7968a --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/onremoved/index.html @@ -0,0 +1,135 @@ +--- +title: bookmarks.onRemoved +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/onRemoved +tags: + - API + - Add-ons + - Bookmarks + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onRemoved +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/onRemoved +--- +<p>{{AddonSidebar()}}</p> + +<p>ブックマークやフォルダが削除された際に発火します。フォルダが再帰的に削除された場合は、そのフォルダに対して 1 回だけ発火し、そのフォルダの中身に関しては発火しません。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.onRemoved.addListener(function( + id, // 文字列 + removeInfo // オブジェクト +) {...}) +browser.bookmarks.onRemoved.removeListener(listener) +browser.bookmarks.onRemoved.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> + </dd> +</dl> + +<dl> + <dd> + <dl class="reference-values"> + <dt><code>id</code></dt> + <dd>削除された要素の ID を表す {{jsxref("string")}}</dd> + </dl> + + <dl class="reference-values"> + <dt><code>removeInfo</code></dt> + <dd>削除された要素の詳細を含んだ {{jsxref("object")}}</dd> + </dl> + </dd> +</dl> + +<h2 id="付随するオブジェクト">付随するオブジェクト</h2> + +<h3 id="removeInfo">removeInfo</h3> + +<dl class="reference-values"> + <dt><code>parentId</code></dt> + <dd>要素の親の ID を表す {{jsxref("string")}}</dd> + <dt><code>index</code></dt> + <dd>この要素が親からみて何番目にあるかを表す 0 以上の整数</dd> + <dt><code>node</code></dt> + <dd>削除された要素に関する詳細を含む {{WebExtAPIRef('bookmarks.BookmarkTreeNode')}}</dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.onRemoved")}}</p> + +<h2 id="Examples">Examples</h2> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">handleRemoved</span><span class="punctuation token">(</span>id<span class="punctuation token">,</span> removeInfo<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Item: "</span> <span class="operator token">+</span> id <span class="operator token">+</span> <span class="string token">" removed"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Title: "</span> <span class="operator token">+</span> removeInfo<span class="punctuation token">.</span>node<span class="punctuation token">.</span>title<span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Url: "</span> <span class="operator token">+</span> removeInfo<span class="punctuation token">.</span>node<span class="punctuation token">.</span>url<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">handleClick</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span>onRemoved<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleRemoved<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleClick<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/remove/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/remove/index.html new file mode 100644 index 0000000000..a76c3f74bc --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/remove/index.html @@ -0,0 +1,96 @@ +--- +title: bookmarks.remove() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/remove +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - remove +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/remove +--- +<p>{{AddonSidebar()}}</p> + +<p><strong><code>bookmarks.remove()</code></strong> は、ブックマークや空のブックマークフォルダを削除するメソッドです。</p> + +<p>ブックマークが見つからなかった、またはフォルダが空ではなかった場合には {{WebExtAPIRef("runtime.lastError")}} がセットされ、エラーの有無はコールバック内で確認できます。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.remove( + id, // 文字列 + callback // 関数(省略可) +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>id</code></dt> + <dd>削除したいブックマーク / 空フォルダの ID を指定する {{jsxref("string")}} です。</dd> + <dt><code>callback</code>{{optional_inline}}</dt> + <dd>ブックマークやフォルダが削除された際に実行される関数です。この関数に渡される引数はありません。</dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.remove")}}</p> + +<h2 id="使用例">使用例</h2> + +<p>以下の例はブックマークを削除するものです。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">onRemoved</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span>chrome<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span>lastError<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>chrome<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span>lastError<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> <span class="keyword token">else</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"bookmark item removed!"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> + +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">remove</span><span class="punctuation token">(</span>bookmarkItemId"<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/removetree/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/removetree/index.html new file mode 100644 index 0000000000..03378dfc79 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/removetree/index.html @@ -0,0 +1,101 @@ +--- +title: bookmarks.removeTree() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/removeTree +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - removeTree +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/removeTree +--- +<p>{{AddonSidebar()}}</p> + +<p><strong><code>bookmarks.removeTree()</code></strong> は、ブックマークフォルダやその要素を再帰的に削除するメソッドです。</p> + +<p>ブックマークが見つからなかった場合は {{WebExtAPIRef("runtime.lastError")}} がセットされ、エラーの有無はコールバック内で確認できます。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.removeTree( + id, // 文字列 + callback // 関数(省略可) +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>id</code></dt> + <dd>子要素とともに削除されるフォルダノードの ID を表す {{jsxref("string")}} です。</dd> + <dt><code>callback</code>{{optional_inline}}</dt> + <dd>ノードが削除された際に実行される関数です。この関数に渡される引数はありません。</dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.removeTree")}}</p> + +<h2 id="使用例">使用例</h2> + +<p>以下の例は、"MDN" という名前のフォルダを探し、それ自身とその子要素をすべて削除するものです。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">onRemoved</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span>chrome<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span>lastError<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>chrome<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span>lastError<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> <span class="keyword token">else</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"bookmark item removed!"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">removeMDN</span><span class="punctuation token">(</span>searchResults<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span>searchResults<span class="punctuation token">.</span>length<span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">removeTree</span><span class="punctuation token">(</span>searchResults<span class="punctuation token">[</span><span class="number token">0</span><span class="punctuation token">]</span><span class="punctuation token">.</span>id<span class="punctuation token">,</span> onRemoved<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">search</span><span class="punctuation token">(</span><span class="punctuation token">{</span> title<span class="punctuation token">:</span> <span class="string token">"MDN"</span> <span class="punctuation token">}</span><span class="punctuation token">,</span> removeMDN<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/search/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/search/index.html new file mode 100644 index 0000000000..4532e33fdd --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/search/index.html @@ -0,0 +1,135 @@ +--- +title: bookmarks.search() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/search +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Method + - Non-standard + - Reference + - Search + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/search +--- +<div>{{AddonSidebar()}}</div> + +<p><strong><code>bookmarks.search()</code></strong> 関数は、指定したクエリにマッチするブックマークを検索するものです。マッチしたブックマークは、{{WebExtAPIRef('bookmarks.BookmarkTreeNode')}} オブジェクトの配列として、指定されたコールバック関数の引数に渡されます。</p> + +<p>入力引数の値や型が不正だった場合、この関数は例外を送出します。エラーメッセージは<a href="https://developer.mozilla.org/ja/Add-ons/WebExtensions/%E3%83%87%E3%83%90%E3%83%83%E3%82%B0">コンソール</a>で確認できます。送出された例外はエラー ID を含んでおらず、またメッセージを変更される可能性があるため、これらを解析するようなコードは書かないでください。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.search( + query, // 文字列またはオブジェクト + callback // 関数 +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>query</code></dt> + <dd>実行するクエリを表す {{jsxref("string")}} または {{jsxref("object")}} です。</dd> + <dd><code>query</code> を文字列で指定する場合、<code>query</code> は 0 個以上の検索項から構成されます。検索項はスペースで区切りますが、複数語からなる句を検索したい場合は引用符でくくります。それぞれの検索項はブックマークの URL やタイトルの部分文字列にマッチします(大文字・小文字は区別されません)。あるブックマークがクエリにマッチするには、クエリの検索項すべてがマッチしなければなりません。</dd> + <dd> + <p><code>query</code> をオブジェクトで指定する場合、以下の 3 つのプロパティのうち 0 個以上を指定することになります。あるブックマークがクエリにマッチするには、指定されたプロパティすべてにおいてマッチしなければなりません。</p> + </dd> + <dd> + <dl class="reference-values"> + <dt><code>query</code>{{optional_inline}}</dt> + <dd>1 つ以上の検索項を含んだ {{jsxref("string")}} を指定します。このフォーマットは <code>query</code> 引数における文字列のフォーマットと同じです。このプロパティ値が {{jsxref("string")}} でなかった場合、 例外が送出されます。</dd> + <dt><code>url</code>{{optional_inline}}</dt> + <dd>ブックマークの URL と完全一致しなければならない {{jsxref("string")}} <code>を指定します。</code>マッチの際に大文字・小文字は区別されず、また末尾のスラッシュも無視されます。</dd> + <dd> + <p>無効な URL を指定した場合、例外が送出されます。</p> + </dd> + </dl> + + <dl class="reference-values"> + <dt><code>title</code>{{optional_inline}}</dt> + <dd>ブックマークのタイトルと完全一致しなければならない {{jsxref("string")}} <code>を指定します。</code>マッチの際には大文字・小文字が区別されます。</dd> + </dl> + </dd> + <dt><code>callback</code></dt> + <dd>クエリの結果が得られた場合に呼び出される関数を指定します。この関数には以下の引数が渡ります。</dd> + <dd> + <dl class="reference-values"> + <dt><code>results</code></dt> + <dd>{{WebExtAPIRef('bookmarks.BookmarkTreeNode')}} オブジェクトの配列であり、各要素はマッチしたブックマークをそれぞれ表しています。何も見つからなかった場合は空の配列となります。</dd> + </dl> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.search")}}</p> + +<h2 id="使用例">使用例</h2> + +<p>以下の例は、ブックマークすべての ID を出力するものです。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">onGot</span><span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">for</span> <span class="punctuation token">(</span>item <span class="keyword token">of</span> bookmarkItems<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>item<span class="punctuation token">.</span>id<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">search</span><span class="punctuation token">(</span><span class="punctuation token">{</span><span class="punctuation token">}</span><span class="punctuation token">,</span> onGot<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>以下の例は、その時にアクティブなタブがブックマークされているかどうかを確認するものです。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">onGot</span><span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span>bookmarkItems<span class="punctuation token">.</span>length<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"active tab is bookmarked"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> <span class="keyword token">else</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"active tab is not bookmarked"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">checkActiveTab</span><span class="punctuation token">(</span>tab<span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">search</span><span class="punctuation token">(</span><span class="punctuation token">{</span>url<span class="punctuation token">:</span> tab<span class="punctuation token">.</span>url<span class="punctuation token">}</span><span class="punctuation token">,</span> onGot<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>checkActiveTab<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は Chromium の <a href="https://developer.chrome.com/extensions/bookmarks#method-search"><code>chrome.bookmarks</code></a> API に基づいています。また、このドキュメントは <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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/bookmarks/update/index.html b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/update/index.html new file mode 100644 index 0000000000..8ceee69300 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/bookmarks/update/index.html @@ -0,0 +1,117 @@ +--- +title: bookmarks.update() +slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/update +tags: + - API + - Add-ons + - Bookmarks + - Extensions + - Method + - Non-standard + - Reference + - Update + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/update +--- +<p>{{AddonSidebar()}}</p> + +<p><strong><code>bookmarks.update()</code></strong> は、ブックマークの URL やタイトル、またはフォルダの名前を更新するメソッドです。</p> + +<p>ブックマーク要素が見つからなかった場合には {{WebExtAPIRef("runtime.lastError")}} がセットされるので、エラーの有無をコールバックで確認できます。</p> + +<h2 id="構文">構文</h2> + +<pre class="brush: js">browser.bookmarks.update( + id, // 文字列 + changes, // オブジェクト + callback // 関数(省略可) +) +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>id</code></dt> + <dd>更新したいブックマーク / フォルダの ID を表す {{jsxref("string")}} です。</dd> + <dt><code>changes</code></dt> + <dd>適用したい変更内容を表す {{jsxref("object")}} であり、以下のプロパティから構成されます。指定しなかったプロパティについて、ブックマークやフォルダが変更されることはありません。<br> + + <dl class="reference-values"> + <dt><code>title</code>{{optional_inline}}</dt> + <dd><code>id</code> がフォルダを表す場合、ブックマークの新しいタイトル / フォルダの新しい名前を指定する {{jsxref("string")}} です。</dd> + <dt><code>url</code>{{optional_inline}}</dt> + <dd>ブックマークの新しい URL を指定する {{jsxref("string")}} です。</dd> + </dl> + </dd> + <dt><code>callback</code>{{optional_inline}}</dt> + <dd>変更が適用された際に実行される関数です。この関数には次の引数が 1 つ渡ります。</dd> + <dd> + <dl class="reference-values"> + <dt><code>result</code></dt> + <dd>更新されたブックマークを表す{{WebExtAPIRef('bookmarks.BookmarkTreeNode')}} オブジェクトです。</dd> + </dl> + </dd> +</dl> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<p>{{Compat("webextensions.api.bookmarks.update")}}</p> + +<h2 id="使用例">使用例</h2> + +<h3 id="フォルダのリネーム">フォルダのリネーム</h3> + +<p>以下の例は、"MDN" という名前のフォルダすべてを "MDN" to "Mozilla Developer Network (MDN)" にリネームするものです。</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">updateFolders</span><span class="punctuation token">(</span>items<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">for</span> <span class="punctuation token">(</span>item <span class="keyword token">of</span> items<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="comment token">// only folders, so skip items with a `url`</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span><span class="operator token">!</span>item<span class="punctuation token">.</span>url<span class="punctuation token">)</span> <span class="punctuation token">{</span> + chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">update</span><span class="punctuation token">(</span>item<span class="punctuation token">.</span>id<span class="punctuation token">,</span> <span class="punctuation token">{</span> + title<span class="punctuation token">:</span> <span class="string token">"Mozilla Developer Network (MDN)"</span> + <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> + <span class="punctuation token">}</span> +<span class="punctuation token">}</span> + +chrome<span class="punctuation token">.</span>bookmarks<span class="punctuation token">.</span><span class="function token">search</span><span class="punctuation token">(</span><span class="punctuation token">{</span> title<span class="punctuation token">:</span> <span class="string token">"MDN"</span> <span class="punctuation token">}</span><span class="punctuation token">,</span> updateFolders<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/bookmarks#method-update"><code>chrome.bookmarks</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.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> |