[英]Firefox-Addon: Add search engine with varying URL and suggestions
my Firefox addon shall add a search engine, that 我的Firefox插件应添加一个搜索引擎,
And I don't see a way to do both at the same time. 而且我看不到同时做这两种方法的方法。
I see two options to add a search engine: 我看到两个添加搜索引擎的选项:
addEngineWithDetails()
allows me to add a search engine with the template URL. addEngineWithDetails()
允许我添加带有模板URL的搜索引擎。 But it does (apparently?) not allow to provide a suggestions URL. 但是(显然吗?)不允许提供建议URL。
addEngine()
allows me to add a search engine that is specified in an XML file. addEngine()
允许我添加XML文件中指定的搜索引擎。 But if have that file saved locally in my addon directory (eg chrome://example-engine/content/search.xml
), how can I change the template URL on runtime? 但是,如果该文件已本地保存在我的插件目录中(例如
chrome://example-engine/content/search.xml
),如何在运行时更改模板URL? And using an online XML is an unsafe options since the internet connection could be broken or bad during the addon install. 而且,使用在线XML是不安全的选择,因为在插件安装期间Internet连接可能断开或损坏。
First fo all, you're right, addEngineWithDetails
does not support suggestions. 首先,您是对的,
addEngineWithDetails
不支持建议。
The way to go would be to use addEngine
(and removeEngine
). 要走的路是使用
addEngine
(和removeEngine
)。
As for the "dynamic" part of your question: While I didn't test it, the implementation seems to happily accept data:
URIs . 至于您问题的“动态”部分:尽管我没有对其进行测试,但该实现似乎很乐意接受
data:
URIs 。 So you could: 因此,您可以:
addEngine
with the data URI. addEngine
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.