diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/mozilla/add-ons/webextensions/api/tabs/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/mozilla/add-ons/webextensions/api/tabs/index.html')
-rw-r--r-- | files/zh-cn/mozilla/add-ons/webextensions/api/tabs/index.html | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/index.html new file mode 100644 index 0000000000..868b3e1238 --- /dev/null +++ b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/index.html @@ -0,0 +1,192 @@ +--- +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 +--- +<div>{{AddonSidebar}}</div> + +<p>与浏览器标签系统进行交互。</p> + +<p>你可以使用该API获取一个已打开标签的列表并且使用各种标准过滤标签,并进行 打开, 刷新,移动,重载,移除操作。该API不能直接访问标签中的主机内容,但是你可以使用 {{WebExtAPIRef("tabs.executeScript()")}} 或者 {{WebExtAPIRef("tabs.insertCSS()")}} APIs,来插入javascript和CSS。</p> + +<p>你可以在不需要任何特殊权限的情况下使用该APIS的大部分, 除了:</p> + +<ul> + <li>获取 <code>Tab.url</code>, <code>Tab.title</code>, and <code>Tab.favIconUrl</code>, 你需要拥有 "tabs" <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a>. 在火狐,这也意味着你需要 "tabs" ,来通过URL使用 {{WebExtAPIRef("tabs.query", "query")}}。</li> + <li>使用 {{WebExtAPIRef("tabs.executeScript()")}} 或者 {{WebExtAPIRef("tabs.insertCSS()")}} 你必须在目标标签拥有 <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">host permission</a> 。</li> +</ul> + +<p>或者你可以仅仅只为当前的活动标签临时的获取这些权限并且仅仅只响应一个显示的用户行为,请查看 <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#activeTab_permission">"activeTab" permission</a>.</p> + +<h2 id="枚举值">枚举值</h2> + +<dl> + <dt>{{WebExtAPIRef("tabs.MutedInfoReason")}}</dt> + <dd>确定一个标签静音与否的原因(用户修改,扩展修改)。</dd> + <dt>{{WebExtAPIRef("tabs.MutedInfo")}}</dt> + <dd>该对象包含一个布尔值只是该标签是否静音,以及最近一次静音的原因。</dd> + <dt>{{WebExtAPIRef("tabs.Tab")}}</dt> + <dd>该值包含了一个标签的信息。</dd> + <dt>{{WebExtAPIRef("tabs.TabStatus")}}</dt> + <dd>指示某个标签是否已经加载完成</dd> + <dt>{{WebExtAPIRef("tabs.WindowType")}}</dt> + <dd>包含该标签的窗口类型。</dd> + <dt>{{WebExtAPIRef("tabs.ZoomSettingsMode")}}</dt> + <dd>定义缩放由浏览器控制或是扩展,或者禁用。</dd> + <dt>{{WebExtAPIRef("tabs.ZoomSettingsScope")}}</dt> + <dd>定义缩放将对某个网址持续生效,或者仅仅只针对该标签。</dd> + <dt>{{WebExtAPIRef("tabs.ZoomSettings")}}</dt> + <dd>定义缩放设置。 {{WebExtAPIRef("tabs.ZoomSettingsMode", "mode")}}, {{WebExtAPIRef("tabs.ZoomSettingsScope", "scope")}}, 和默认缩放比例。</dd> +</dl> + +<h2 id="属性">属性</h2> + +<dl> + <dt>{{WebExtAPIRef("tabs.TAB_ID_NONE")}}</dt> + <dd>给予非浏览器标签的一个特殊ID值 (比如,在开发工具中的标签)。</dd> +</dl> + +<h2 id="方法">方法</h2> + +<dl> + <dt>{{WebExtAPIRef("tabs.connect()")}}</dt> + <dd>在运行于该标签的任何 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">content scripts </a> 和该扩展的后台脚本(或者其他的比如弹出菜单脚本或者设置页面脚本)间创建一个消息连接。</dd> + <dt>{{WebExtAPIRef("tabs.create()")}}</dt> + <dd>创建一个新标签。</dd> + <dt>{{WebExtAPIRef("tabs.captureVisibleTab()")}}</dt> + <dd>创意一个数据统一资源标识符解码在规定窗口中当前活动标签的可视区域重的一个图片。</dd> + <dt>{{WebExtAPIRef("tabs.detectLanguage()")}}</dt> + <dd>检查在一个标签中的主要语言。</dd> + <dt>{{WebExtAPIRef("tabs.duplicate()")}}</dt> + <dd>复制一个标签</dd> + <dt>{{WebExtAPIRef("tabs.executeScript()")}}</dt> + <dd>向一个页面注入脚本。</dd> + <dt>{{WebExtAPIRef("tabs.get()")}}</dt> + <dd>取回制定标签的详细信息。</dd> + <dt>{{WebExtAPIRef("tabs.getAllInWindow()")}} {{deprecated_inline}}</dt> + <dd>获取指定窗口所有标签的详细信息。</dd> + <dt>{{WebExtAPIRef("tabs.getCurrent()")}}</dt> + <dd>返回一个 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/Tabs/Tab" title="This type contains information about a tab."><code>tabs.Tab</code></a> 对象包含了该脚本当前的宿主标签的信息。</dd> + <dt>{{WebExtAPIRef("tabs.getSelected()")}} {{deprecated_inline}}</dt> + <dd>获取在指定窗口被选定的标签。</dd> + <dt>{{WebExtAPIRef("tabs.getZoom()")}}</dt> + <dd>获取制定标签的缩放系数。</dd> + <dt>{{WebExtAPIRef("tabs.getZoomSettings()")}}</dt> + <dd>获取指定标签的缩放设置。</dd> + <dt>{{WebExtAPIRef("tabs.highlight()")}}</dt> + <dd>高亮显示一个或多个标签。</dd> + <dt>{{WebExtAPIRef("tabs.insertCSS()")}}</dt> + <dd>向一个页面注入CSS。</dd> + <dt>{{WebExtAPIRef("tabs.removeCSS()")}}</dt> + <dd>移除之前调用{{WebExtAPIRef("tabs.insertCSS()")}} 注入的一个css。</dd> + <dt>{{WebExtAPIRef("tabs.move()")}}</dt> + <dd>移动一个或多个标签页到同一窗口的一个新的位置或是到不同窗口。</dd> + <dt>{{WebExtAPIRef("tabs.query()")}}</dt> + <dd>获取所有包含指定属性的标签,如果没有属性则获取所有标签。</dd> + <dt>{{WebExtAPIRef("tabs.reload()")}}</dt> + <dd>重在一个标签,可选的可以绕过本地缓存。</dd> + <dt>{{WebExtAPIRef("tabs.remove()")}}</dt> + <dd>关闭一个或多个标签。</dd> + <dt>{{WebExtAPIRef("tabs.sendMessage()")}}</dt> + <dd>向一个指定标签的content script 发送单个消息。</dd> + <dt>{{WebExtAPIRef("tabs.sendRequest()")}} {{deprecated_inline}}</dt> + <dd>向一个指定标签的content script 发送一个单一请求。 <strong>过时</strong>: 请使用 {{WebExtAPIRef("tabs.sendMessage()")}} 替代。</dd> + <dt>{{WebExtAPIRef("tabs.setZoom()")}}</dt> + <dd>缩放指定标签。</dd> + <dt>{{WebExtAPIRef("tabs.setZoomSettings()")}}</dt> + <dd>为一个制定标签设置缩放选项。</dd> + <dt>{{WebExtAPIRef("tabs.update()")}}</dt> + <dd>导航一个标签到新的地址,或是修改其它的属性。</dd> +</dl> + +<h2 id="Events">Events</h2> + +<dl> + <dt>{{WebExtAPIRef("tabs.onActivated")}}</dt> + <dd>当窗口活动标签改变时触发,注意当该消息触发时,标签地址可能没有被设置。</dd> + <dt>{{WebExtAPIRef("tabs.onActiveChanged")}} {{deprecated_inline}}</dt> + <dd> <strong>已过时:</strong> 请使用 {{WebExtAPIRef("tabs.onActivated")}} 代替。</dd> + <dt>{{WebExtAPIRef("tabs.onAttached")}}</dt> + <dd>当一个标签被附加到一个窗口时触发,因为他可能在窗口间移动。</dd> + <dt>{{WebExtAPIRef("tabs.onCreated")}}</dt> + <dd>当一个标签被创建时触发,注意当该事件触发时可能没有设置地址。</dd> + <dt>{{WebExtAPIRef("tabs.onDetached")}}</dt> + <dd>当一个标签脱离一个窗口时被触发。</dd> + <dt>{{WebExtAPIRef("tabs.onHighlightChanged")}} {{deprecated_inline}}</dt> + <dd><strong>过时:</strong> 请使用 {{WebExtAPIRef("tabs.onHighlighted")}} 代替。</dd> + <dt>{{WebExtAPIRef("tabs.onHighlighted")}}</dt> + <dd>当一个标签被高亮显示或是被选中时触发。</dd> + <dt>{{WebExtAPIRef("tabs.onMoved")}}</dt> + <dd>当一个标签在一个窗口内移动时被触发。</dd> + <dt>{{WebExtAPIRef("tabs.onRemoved")}}</dt> + <dd>当一个标签关闭时被处罚。</dd> + <dt>{{WebExtAPIRef("tabs.onReplaced")}}</dt> + <dd>当一个标签因为预载取代另一个标签时被触发。</dd> + <dt>{{WebExtAPIRef("tabs.onSelectionChanged")}} {{deprecated_inline}}</dt> + <dd> <strong>以过时:</strong> 请使用 {{WebExtAPIRef("tabs.onActivated")}} 代替。</dd> + <dt>{{WebExtAPIRef("tabs.onUpdated")}}</dt> + <dd>当一个标签被更新时触发。</dd> + <dt>{{WebExtAPIRef("tabs.onZoomChange")}}</dt> + <dd>当一个标签被缩放时触发</dd> +</dl> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<p>{{Compat("webextensions.api.tabs")}}</p> + +<div class="hidden note"> +<p>The "Chrome incompatibilities" section is included from <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> using the <a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p> + +<p>If you need to update this content, edit <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/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>Acknowledgements</strong> + +<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs"><code>chrome.tabs</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p> + +<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p> +</div> + +<div class="hidden"> +<pre>// 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> |