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 scripting.ExecutionWorld #25289

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,34 @@
---
title: scripting.ExecutionWorld
slug: Mozilla/Add-ons/WebExtensions/API/scripting/ExecutionWorld
l10n:
sourceCommit: b8a0743ca8b1e1b1b1a95cc93a4413c020f11262
---

{{AddonSidebar}}

指定通过 {{WebExtAPIRef("scripting.executeScript()")}} 插入或 {{WebExtAPIRef("scripting.registerContentScripts()")}} 注册的脚本的执行环境。
PassionPenguin marked this conversation as resolved.
Show resolved Hide resolved

## 类型

该类型的取值是字符串,可能取值包括:

- `ISOLATED`

默认的 [内容脚本](/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Content_scripts) 执行环境。该环境与页面上下文隔离:虽然它们共享同一个文档,但全局作用域和可用的 API 不同。

- `MAIN`

网页执行环境。该环境与网页共享而没有隔离。在该环境中的脚本无法访问仅供内容脚本使用的 API。

> [!WARNING]
> 由于缺乏隔离,网页可以检测并干扰执行的代码。除非网页可以读取、访问或修改通过执行的代码流动的逻辑或数据,否则不要使用 `MAIN` 环境。

{{WebExtExamples("h2")}}

## 浏览器兼容性

{{Compat}}

> [!NOTE]
> 该 API 基于 Chromium 的 [`chrome.scripting`](https://developer.chrome.google.cn/docs/extensions/reference/api/scripting#type-ExecutionWorld) API。
Loading