From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- .../add-ons/webextensions/api/tabs/get/index.html | 74 +++++++++ .../add-ons/webextensions/api/tabs/hide/index.html | 79 +++++++++ .../add-ons/webextensions/api/tabs/index.html | 179 +++++++++++++++++++++ 3 files changed, 332 insertions(+) create mode 100644 files/ru/mozilla/add-ons/webextensions/api/tabs/get/index.html create mode 100644 files/ru/mozilla/add-ons/webextensions/api/tabs/hide/index.html create mode 100644 files/ru/mozilla/add-ons/webextensions/api/tabs/index.html (limited to 'files/ru/mozilla/add-ons/webextensions/api/tabs') diff --git a/files/ru/mozilla/add-ons/webextensions/api/tabs/get/index.html b/files/ru/mozilla/add-ons/webextensions/api/tabs/get/index.html new file mode 100644 index 0000000000..25a2126d65 --- /dev/null +++ b/files/ru/mozilla/add-ons/webextensions/api/tabs/get/index.html @@ -0,0 +1,74 @@ +--- +title: tabs.get() +slug: Mozilla/Add-ons/WebExtensions/API/tabs/get +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/get +--- +
{{AddonSidebar()}}
+ +

Получает сведения об указанной вкладке.

+ +

Синтаксис

+ +
browser.tabs.get(
+  tabId,              // integer
+  function(tab) {...} // function
+)
+
+ +

Параметры

+ +
+
tabId
+
integer.
+
callback
+
function. Функция принимает следующие аргументы: +
+
tab
+
{{WebExtAPIRef('tabs.Tab')}}.
+
+
+
+ +

Совместимость с браузерами

+ +

{{Compat("webextensions.api.tabs.get")}}

+ +

Примеры

+ +

{{WebExtExamples}}

+ +
Благодарность + +

Этот API основан на Chromium chrome.tabs API. Это документация получена из tabs.json в коде Chromium.

+
+ + diff --git a/files/ru/mozilla/add-ons/webextensions/api/tabs/hide/index.html b/files/ru/mozilla/add-ons/webextensions/api/tabs/hide/index.html new file mode 100644 index 0000000000..a91d67f008 --- /dev/null +++ b/files/ru/mozilla/add-ons/webextensions/api/tabs/hide/index.html @@ -0,0 +1,79 @@ +--- +title: tabs.hide() +slug: Mozilla/Add-ons/WebExtensions/API/tabs/hide +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/hide +--- +
{{AddonSidebar()}}
+ +

Hides one or more tabs.

+ +

Hidden tabs are no longer visible in the browser's tabstrip. Hidden tabs are not automatically discarded: the code running in them continues to run. You can explicitly discard tabs whenever you hide them: although this is not appropriate in all situations, it will help to reduce the resources used by the browser.

+ +

This is an asynchronous function that returns a Promise.

+ +

Not all tabs are eligible for being hidden:

+ + + +

The first time an extension hides a tab, the browser will tell the user that the tab is being hidden, show them how they can access the hidden tab, and give them the option of disabling the extension instead.

+ +

To use this API you must have the "tabHide" permission.

+ +

Syntax

+ +
var hiding = browser.tabs.hide(
+  tabIds          // integer or integer array
+)
+
+ +

Parameters

+ +
+
tabIds
+
integer or array of integer. The IDs of the tab or tabs to hide.
+
If any of these tabs are not eligible for being hidden, they will not be hidden, but the call will still succeed and eligible tabs will still be hidden. For example, if you pass [1, 3], and 1 identifies the active tab, then only 3 will be hidden.
+
However, if any of the tab IDs are invalid, the call will fail and no tabs will be hidden.
+
+ +

Return value

+ +

A Promise that will be fulfilled with an array containing the IDs of the tabs that were hidden. If any error occurs, the promise will be rejected with an error message.

+ +

Browser compatibility

+ + + +

{{Compat("webextensions.api.tabs.hide")}}

+ +

Examples

+ +

Hide a single tab:

+ +
function onHidden() {
+  console.log(`Hidden`);
+}
+
+function onError(error) {
+  console.log(`Error: ${error}`);
+}
+
+browser.tabs.hide(2).then(onHidden, onError);
+ +

Hide multiple tabs:

+ +
function onHidden() {
+  console.log(`Hidden`);
+}
+
+function onError(error) {
+  console.log(`Error: ${error}`);
+}
+
+browser.tabs.hide([15, 14, 1]).then(onHidden, onError);
+ +

{{WebExtExamples}}

diff --git a/files/ru/mozilla/add-ons/webextensions/api/tabs/index.html b/files/ru/mozilla/add-ons/webextensions/api/tabs/index.html new file mode 100644 index 0000000000..696329aa4f --- /dev/null +++ b/files/ru/mozilla/add-ons/webextensions/api/tabs/index.html @@ -0,0 +1,179 @@ +--- +title: tabs +slug: Mozilla/Add-ons/WebExtensions/API/tabs +tags: + - API + - Add-ons + - Extensions + - Interface + - NeedsTranslation + - Non-standard + - Reference + - TopicStub + - WebExtensions + - tabs +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs +--- +
{{AddonSidebar}}
+ +

Interact with the browser's tab system. You can use this API to get a list of opened tabs and to create, modify, and rearrange tabs in the browser.

+ +

You can use most of this API without any special permission. However, to access Tab.url, Tab.title, and Tab.faviconUrl, you need to have the "tabs" permission. In Firefox this also means you need "tabs" to {{WebExtAPIRef("tabs.query", "query")}} by URL.

+ +

Types

+ +
+
{{WebExtAPIRef("tabs.MutedInfoReason")}}
+
An event that caused a muted state change.
+
{{WebExtAPIRef("tabs.MutedInfo")}}
+
Tab muted state and the reason for the last state change.
+
{{WebExtAPIRef("tabs.Tab")}}
+
Contains various properties of a single tab.
+
{{WebExtAPIRef("tabs.ZoomSettingsMode")}}
+
Defines how zoom changes are handled, i.e. which entity is responsible for the actual scaling of the page; defaults to automatic.
+
{{WebExtAPIRef("tabs.ZoomSettingsScope")}}
+
Defines whether zoom changes will persist for the page's origin, or only take effect in this tab; defaults to per-origin when in automatic mode, and per-tab otherwise.
+
{{WebExtAPIRef("tabs.ZoomSettings")}}
+
Defines how zoom changes in a tab are handled and at what scope.
+
{{WebExtAPIRef("tabs.TabStatus")}}
+
Whether the tabs have completed loading.
+
{{WebExtAPIRef("tabs.WindowType")}}
+
The type of window.
+
+ +

Properties

+ +
+
{{WebExtAPIRef("tabs.TAB_ID_NONE")}}
+
An ID which represents the absence of a browser tab.
+
+ +

Functions

+ +
+
{{WebExtAPIRef("tabs.get()")}}
+
Retrieves details about the specified tab.
+
{{WebExtAPIRef("tabs.getCurrent()")}}
+
Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example: a background page or popup view).
+
{{WebExtAPIRef("tabs.connect()")}}
+
Connects to the content script(s) in the specified tab. The {{WebExtAPIRef('runtime.onConnect')}} event is fired in each content script running in the specified tab for the current extension. For more details, see content script messaging.
+
{{WebExtAPIRef("tabs.sendRequest()")}}
+
Sends a single request to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The {{WebExtAPIRef('extension.onRequest')}} event is fired in each content script running in the specified tab for the current extension.
+
{{WebExtAPIRef("tabs.sendMessage()")}}
+
Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The {{WebExtAPIRef('runtime.onMessage')}} event is fired in each content script running in the specified tab for the current extension.
+
{{WebExtAPIRef("tabs.getSelected()")}}
+
Gets the tab that is selected in the specified window.
+
{{WebExtAPIRef("tabs.getAllInWindow()")}}
+
Gets details about all tabs in the specified window.
+
{{WebExtAPIRef("tabs.create()")}}
+
Creates a new tab.
+
{{WebExtAPIRef("tabs.duplicate()")}}
+
Duplicates a tab.
+
{{WebExtAPIRef("tabs.query()")}}
+
Gets all tabs that have the specified properties, or all tabs if no properties are specified.
+
{{WebExtAPIRef("tabs.highlight()")}}
+
Highlights the given tabs.
+
{{WebExtAPIRef("tabs.update()")}}
+
Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
+
{{WebExtAPIRef("tabs.move()")}}
+
Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows.
+
{{WebExtAPIRef("tabs.reload()")}}
+
Reload a tab.
+
{{WebExtAPIRef("tabs.remove()")}}
+
Closes one or more tabs.
+
{{WebExtAPIRef("tabs.detectLanguage()")}}
+
Detects the primary language of the content in a tab.
+
{{WebExtAPIRef("tabs.captureVisibleTab()")}}
+
Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
+
{{WebExtAPIRef("tabs.executeScript()")}}
+
Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
+
{{WebExtAPIRef("tabs.insertCSS()")}}
+
Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
+
{{WebExtAPIRef("tabs.setZoom()")}}
+
Zooms a specified tab.
+
{{WebExtAPIRef("tabs.getZoom()")}}
+
Gets the current zoom factor of a specified tab.
+
{{WebExtAPIRef("tabs.setZoomSettings()")}}
+
Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab.
+
{{WebExtAPIRef("tabs.getZoomSettings()")}}
+
Gets the current zoom settings of a specified tab.
+
+ +

Events

+ +
+
{{WebExtAPIRef("tabs.onCreated")}}
+
Fired when a tab is created. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set.
+
{{WebExtAPIRef("tabs.onUpdated")}}
+
Fired when a tab is updated.
+
{{WebExtAPIRef("tabs.onMoved")}}
+
Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response. This event is not fired when a tab is moved between windows. For that, see {{WebExtAPIRef('tabs.onDetached')}}.
+
{{WebExtAPIRef("tabs.onSelectionChanged")}}
+
Fires when the selected tab in a window changes.
+
{{WebExtAPIRef("tabs.onActiveChanged")}}
+
Fires when the selected tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to {{WebExtAPIRef('tabs.onUpdated')}} events to be notified when a URL is set.
+
{{WebExtAPIRef("tabs.onActivated")}}
+
Fires when the active tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set.
+
{{WebExtAPIRef("tabs.onHighlightChanged")}}
+
Fired when the highlighted or selected tabs in a window changes.
+
{{WebExtAPIRef("tabs.onHighlighted")}}
+
Fired when the highlighted or selected tabs in a window changes.
+
{{WebExtAPIRef("tabs.onDetached")}}
+
Fired when a tab is detached from a window, for example because it is being moved between windows.
+
{{WebExtAPIRef("tabs.onAttached")}}
+
Fired when a tab is attached to a window, for example because it was moved between windows.
+
{{WebExtAPIRef("tabs.onRemoved")}}
+
Fired when a tab is closed.
+
{{WebExtAPIRef("tabs.onReplaced")}}
+
Fired when a tab is replaced with another tab due to prerendering or instant.
+
{{WebExtAPIRef("tabs.onZoomChange")}}
+
Fired when a tab is zoomed.
+
+ +

Browser compatibility

+ +

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

+ + + +

{{WebExtExamples("h2")}}

+ +
Acknowledgements + +

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

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