简体   繁体   English

如何以编程方式获取 chrome 扩展 ID

[英]How to programmatically get the chrome extension ID

I am trying to open/interact with the chrome extension from the webpage in my local(Not installed the chrome extension from the web store).我正在尝试从本地网页打开/与 chrome 扩展程序交互(未安装 web 商店的 chrome 扩展程序)。 For that, i have this piece of code为此,我有这段代码

chrome.runtime.sendMessage(extensionId, {}, function(){ // code })

Here extensionId is the ID which i manually copied from the chrome extension.这里extensionId是我从 chrome 扩展中手动复制的 ID。 And it is working.它正在工作。

Is there any way to get the chrome extension ID programmatically in the webpage?有什么方法可以在网页中以编程方式获取 chrome 扩展 ID? Or is there any other way to open/interact with the chrome extension programmatically?或者是否有任何其他方式以编程方式打开/与 chrome 扩展程序交互?

This is a little old, but this answer to my question answers you directly.这有点老了,但是我的问题的这个答案直接回答了你。 You may use chrome.runtime.id to fetch this value.您可以使用chrome.runtime.id来获取此值。 Cheers干杯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM