From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../webextensions/api/pageaction/index.html | 106 +++++++++++++++++++++ .../api/pageaction/onclicked/index.html | 104 ++++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 files/ja/mozilla/add-ons/webextensions/api/pageaction/index.html create mode 100644 files/ja/mozilla/add-ons/webextensions/api/pageaction/onclicked/index.html (limited to 'files/ja/mozilla/add-ons/webextensions/api/pageaction') diff --git a/files/ja/mozilla/add-ons/webextensions/api/pageaction/index.html b/files/ja/mozilla/add-ons/webextensions/api/pageaction/index.html new file mode 100644 index 0000000000..9aa608ef46 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/pageaction/index.html @@ -0,0 +1,106 @@ +--- +title: pageAction +slug: Mozilla/Add-ons/WebExtensions/API/pageAction +tags: + - API + - Add-ons + - Extensions + - Interface + - Non-standard + - Reference + - WebExtensions + - pageAction +translation_of: Mozilla/Add-ons/WebExtensions/API/pageAction +--- +
{{AddonSidebar}}
+ +

ページアクション は、ブラウザーのアドレスバーの中のクリックできるアイコンです。

+ +

+ +

You can listen for clicks on the icon, or specify a popup that will open when the icon is clicked.

+ +

If you specify a popup, you can define its contents and behavior using HTML, CSS, and JavaScript, just like a normal web page. JavaScript running in the popup gets access to all the same WebExtension APIs as your background scripts.

+ +

You can define most of a page action's properties declaratively using the page_action key in your manifest.json, but can also redefine them programmatically using this API.

+ +

Page actions are for actions that are only relevant to particular pages. If your icon should always be available, use a browser action instead.

+ +

+ +
+
{{WebExtAPIRef("pageAction.ImageDataType")}}
+
Pixel data for an image.
+
+ +

関数

+ +
+
{{WebExtAPIRef("pageAction.show()")}}
+
Shows the page action for a given tab.
+
{{WebExtAPIRef("pageAction.hide()")}}
+
Hides the page action for a given tab.
+
{{WebExtAPIRef("pageAction.setTitle()")}}
+
Sets the page action's title. This is displayed in a tooltip over the page action.
+
{{WebExtAPIRef("pageAction.getTitle()")}}
+
Gets the page action's title.
+
{{WebExtAPIRef("pageAction.setIcon()")}}
+
Sets the page action's icon.
+
{{WebExtAPIRef("pageAction.setPopup()")}}
+
Sets the URL for the page action's popup.
+
{{WebExtAPIRef("pageAction.getPopup()")}}
+
Gets the URL for the page action's popup.
+
{{WebExtAPIRef("pageAction.openPopup()")}}
+
Opens the page action's popup.
+
+ +

イベント

+ +
+
{{WebExtAPIRef("pageAction.onClicked")}}
+
Fired when a page action icon is clicked. This event will not fire if the page action has a popup.
+
+ +

ブラウザ実装状況

+ +

{{Compat("webextensions.api.pageAction")}}

+ +

{{WebExtExamples("h2")}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.pageAction API. This documentation is derived from page_action.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ja/mozilla/add-ons/webextensions/api/pageaction/onclicked/index.html b/files/ja/mozilla/add-ons/webextensions/api/pageaction/onclicked/index.html new file mode 100644 index 0000000000..aa25bd76aa --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/pageaction/onclicked/index.html @@ -0,0 +1,104 @@ +--- +title: pageAction.onClicked +slug: Mozilla/Add-ons/WebExtensions/API/pageAction/onClicked +translation_of: Mozilla/Add-ons/WebExtensions/API/pageAction/onClicked +--- +
{{AddonSidebar()}}
+ +

ページアクションのアイコンがクリックされたときに発火します。ページアクションがポップアップを持っているならこのイベントは発火しません。

+ +

右クリックのアクションを定義するには、{{WebExtAPIRef('contextMenus')}} APIを"page_action" {{WebExtAPIRef('contextMenus/ContextType', 'context type', '', 'nocode')}}とともに使ってください。

+ +

書式

+ +
browser.pageAction.onClicked.addListener(listener)
+browser.pageAction.onClicked.removeListener(listener)
+browser.pageAction.onClicked.hasListener(listener)
+
+ +

イベントは3つの関数を持ちます:

+ +
+
addListener(callback)
+
このイベントにリスナーを追加します。Adds a listener to this event.
+
removeListener(listener)
+
このイベントのリスニングを停止します。引数listenerは削除するリスナーです。
+
hasListener(listener)
+
listenerがイベントに登録されているかを調べます。リスニング中であればtrueを、そうれなければfalseを返します。
+
+ +

addListenerの書式

+ +

パラメータ

+ +
+
callback
+
+

イベント発生時に呼び出される関数です。関数は次の引数を渡されます:

+ +
+
tab
+
ページアクションがクリックされたタブの{{WebExtAPIRef('tabs.Tab')}}オブジェクト。
+
+
+
+ +

ブラウザ互換性

+ + + +

{{Compat("webextensions.api.pageAction.onClicked")}}

+ +

+ +

ユーザがページアクションをクリックしたとき、それを隠し、アクティブタブを"http://chilloutandwatchsomecatgifs.com/"に誘導します:

+ +
var CATGIFS = "http://chilloutandwatchsomecatgifs.com/";
+
+browser.pageAction.onClicked.addListener((tab) => {
+  browser.pageAction.hide(tab.id);
+  browser.tabs.update({url: CATGIFS});
+});
+
+browser.pageAction.onClicked.addListener(function () {
+});
+ +

{{WebExtExamples}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.pageAction API. This documentation is derived from page_action.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + -- cgit v1.2.3-54-g00ecf