gpt4 book ai didi

google-chrome - list 文件在 Chrome 应用程序中可以是动态的吗?

转载 作者:行者123 更新时间:2023-12-05 05:24:41 26 4
gpt4 key购买 nike

我正在编写一个与网页通信的 Chrome 应用程序。为此,我在 list 文件中添加了类似的内容。

"externally_connectable": {
"matches": ["*://*.example.com/*"]
}

但是“example.com”必须是动态的,因为每个客户都有自己的一个网络服务器。

是否有可能,用户(安装应用程序的人)可以更改可外部连接的站点。

最佳答案

还有一种网页可以通过内容脚本与扩展通信的替代方法。如果网页和扩展都由您完成,则可以使用这种方法。

例如

web page <--> content script of extension <--> background script of extension <--> native application

对于网页内容脚本的扩展通信使用window.postMessagewindow.addEventListener

对于 Google Chrome 浏览器,

对于扩展通信后台脚本的扩展内容脚本,使用 chrome.runtime.sendMessagechrome.runtime.onMessage.addListener

对于 native 应用程序通信扩展的后台脚本,请使用 chrome.runtime.sendNativeMessage

请确保您的代码具有必要的安全性。

关于google-chrome - list 文件在 Chrome 应用程序中可以是动态的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34147166/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com