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

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

语法

js
browser.runtime.getManifest();

参数

无。

返回值

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

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
getManifest

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

示例

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

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

示例扩展

备注: This API is based on Chromium's chrome.runtime API. This documentation is derived from runtime.json in the Chromium code.