多功能框 API |针对特定关键字打开特定窗口
我正在尝试创建一个多功能框快捷方式,因此当用户键入 cp command 或 cp command 2 时,它将打开窗口 1 或窗口 2,但它会打开两个窗口都位于“cp”或“cp {此处任何内容}”上。
我是否错过了 API 中的某些内容?
背景.html
<script>
chrome.omnibox.onInputChanged.addListener(
function sharePage(tweet, suggest) {
suggest([
{content: "tweet", description: "Share on Twitter"}
]);
});
//
chrome.omnibox.onInputEntered.addListener(
function sharePage(tweet) {
chrome.tabs.getSelected(null, function (tab) {
var url = "https://twitter.com/home?status=Check%20out%20" + encodeURIComponent(tab.url) + "%20via @Chromeplete"
chrome.tabs.create ({"url": url});
});
});
</script>
<script>
chrome.omnibox.onInputChanged.addListener(
function sharePage(post, suggest) {
suggest([
{content: "post", description: "Share on Facebook"}
]);
});
//
chrome.omnibox.onInputEntered.addListener(
function sharePage(post) {
chrome.tabs.getSelected(null, function (tab) {
var url = "https://www.facebook.com/sharer.php?u" + encodeURIComponent(tab.url) + "&appid=127651283979691"
chrome.tabs.create ({"url": url});
});
});
</script>
I'm trying to create an omnibox shortcut, so when a user types cp command
or cp command 2
it will open either window 1, or window 2, but instead it opens both windows on "cp" or "cp {anything here}".
Have I missed something from the API?
background.html
<script>
chrome.omnibox.onInputChanged.addListener(
function sharePage(tweet, suggest) {
suggest([
{content: "tweet", description: "Share on Twitter"}
]);
});
//
chrome.omnibox.onInputEntered.addListener(
function sharePage(tweet) {
chrome.tabs.getSelected(null, function (tab) {
var url = "https://twitter.com/home?status=Check%20out%20" + encodeURIComponent(tab.url) + "%20via @Chromeplete"
chrome.tabs.create ({"url": url});
});
});
</script>
<script>
chrome.omnibox.onInputChanged.addListener(
function sharePage(post, suggest) {
suggest([
{content: "post", description: "Share on Facebook"}
]);
});
//
chrome.omnibox.onInputEntered.addListener(
function sharePage(post) {
chrome.tabs.getSelected(null, function (tab) {
var url = "https://www.facebook.com/sharer.php?u" + encodeURIComponent(tab.url) + "&appid=127651283979691"
chrome.tabs.create ({"url": url});
});
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该是这样的:
Should be something like this: