检查Chrome扩展程序是否以解压模式安装 [英] Check if Chrome extension installed in unpacked mode

查看:170
本文介绍了检查Chrome扩展程序是否以解压模式安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法检测我是运行从我的.crx文件安装的扩展,还是通过加载解压扩展...按钮加载扩展?

Is there a way to detect whether I'm running an extension that was installed from my .crx file or the extension was loaded as via 'Load unpacked extension...' button?

我知道这种情况下的ID差异,但我不想依赖代码中的硬编码字符串。

I'm aware about ID differences in that case, but I don't want to rely on hardcoded strings in the code.

推荐答案

如果从从我的 .crx 文件中安装,则意味着从Chrome Web Store安装,您可以简单地检查扩展清单。 json 获取 update_url 属性的值。 CWS在你上传你的扩展时添加它。

If by "installed from my .crx file" you mean installed from Chrome Web Store you can simply check extension manifest.json for value of update_url attribute. CWS adds it when you upload your extension.

如果你有一个自托管的 .crx 文件,扩展信息使用 chrome.management.getSelf() 并检查返回的 installType rel =noreferrer> ExtensionInfo 对象。如果它表示development,这意味着扩展程序在开发者模式下被解压缩。 normal表示它是从 .crx 文件安装的。

If you have a self-hosted .crx file, get your extension information using chrome.management.getSelf() and check installType of returned ExtensionInfo object. If it says "development" that means that extension was loaded unpacked in developer mode. "normal" means that it was installed from .crx file.

这篇关于检查Chrome扩展程序是否以解压模式安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆