读取主文件信息方法 - runtime.getManifest()

该方法会获取一个完整的主文件 manifest.json,并返回一个序列化后的 JSON 对象。

语法

js
browser.runtime.getManifest();

参数

无。

返回值

是一个能表示主文件所有信息的 JSON 对象。

浏览器兼容性

BCD tables only load in the browser

示例

取得主文件中的 name 特性的值,并输出到控制台:

js
var manifest = browser.runtime.getManifest();
console.log(manifest.name);

Example extensions

备注: This API is based on Chromium's chrome.runtime API. This documentation is derived from runtime.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.