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

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

语法

browser.runtime.getManifest()

参数

无.

返回值

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

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxOperaFirefox for Android
Basic supportChrome Full support 22Edge Full support 14Firefox Full support 45Opera Full support 15Firefox Android Full support 48

Legend

Full support  
Full support

示例

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

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

Example extensions

Acknowledgements

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.

文档标签和贡献者

此页面的贡献者: taadis
最后编辑者: taadis,