Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zh-CN: create pageAction.isShown() #25275

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: pageAction.isShown()
slug: Mozilla/Add-ons/WebExtensions/API/pageAction/isShown
l10n:
sourceCommit: 43e3ff826b7b755b05986c99ada75635c01c187c
---

{{AddonSidebar}}

如果在指定的标签页中页面操作正在显示中,则返回 `true`。

这是一个返回 [`Promise`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise) 的异步函数。

## 语法

```js-nolint
let gettingIsShown = browser.pageAction.isShown(
details // 对象
)
```

### 参数

- `details`

- : `object`。包含要检查的 `tabId` 的对象。

- `tabId`
- : `integer`。要检查的标签页的 ID。

### 返回值

[`Promise`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise),如果在指定的标签页中拓展的页面操作正在显示。则兑现为 `true`,否则兑现为 `false`。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
[`Promise`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise),如果在指定的标签页中拓展的页面操作正在显示。则兑现为 `true`,否则兑现为 `false`
[`Promise`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise),如果在指定的标签页中拓展的页面操作正在显示。则兑现为 `true`,否则兑现为 `false`


## 浏览器兼容性

{{Compat}}

## 示例

Check the state of the currently active tab:

```js
async function shownInActiveTab() {
let tabs = await browser.tabs.query({
currentWindow: true,
active: true,
});
let shown = await browser.pageAction.isShown({
tabId: tabs[0].id,
});
console.log(shown);
}
```

{{WebExtExamples}}
Loading