gpt4 book ai didi

google-chrome - 没有特定关键字的 Chrome 多功能框事件?

转载 作者:行者123 更新时间:2023-12-04 03:01:36 25 4
gpt4 key购买 nike

我确实想检查在 Chrome 多功能框中编写的内容并重定向到正确的页面。

仍然,我不能使用特定的关键字,因为我确实想将 BUG-1234 之类的东西重定向到 http://bugs.example.com/BUG-1234

我确实有一个正则表达式(因为 BUG 部分可以有很多值)。

我该怎么做?

最佳答案

在多功能框的帮助下,Chrome 扩展程序可以为您提供帮助。

如果我在输入 BUG-1234 并在 Omnibox 中按 Enter 时理解正确的话, 你的网页 URL 应该是 http://bugs.example.com/BUG-1234

演示

我使用关键字作为

"keyword": "BUG"

BUG,您可以根据功能更改它。所以当你在chrome Omnibox中输入B+U+G时, 搜索提供者添加了一个自定义层,如下所示

图片 1)

Beginning Screen

当您输入 1234 并按 Enter 选择建议的 URL Open Bug %s ? in Omnibox ,如图所示

图片 2)

enter image description here

它会打开一个带有此处所示 URL 的网页,其中我使用 http://bugs.example.com 作为测试 URL,可以进一步扩展。

图 3)

enter image description here

list .json

注册后台页面和Omnibox使用 Chrome 扩展程序,并添加相关权限。

{
"name": "Bug Tracker",
"description": "This integrates chrome omnibox with bug search",
"version": "1",
"manifest_version": 2,
"background": {
"scripts": [
"background.js"
]
},
"omnibox": {
"keyword": "BUG"
},
"permissions": [
"<all_urls>"
]
}

背景.js

自定义建议脚本

//Set Text to show for custom suggested URL(s)
chrome.omnibox.setDefaultSuggestion({
"description": "Open Bug %s ?"
});

//Fired when Enter or a suggested Link is selected
chrome.omnibox.onInputEntered.addListener(function (bugId) {
//Use your custom URL
chrome.tabs.update({
"url": "http://bugs.example.com/BUG-" + bugId
}, function () {
console.log("Bug Page is open");
});
console.log("Input Entered is " + bugId);
});

引用资料

关于google-chrome - 没有特定关键字的 Chrome 多功能框事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14364358/

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