简体   繁体   English

如何设置将快捷键关联到我的Chrome扩展程序browser_action?

[英]how to set associate a hotkey to my chrome extension browser_action?

I have set up a hotkey in my manifest.json file, and a bogus listener in my background.js 我在manifest.json文件中设置了一个热键,并在background.js中设置了虚假的监听器

If i hit the hotkey combination, it works. 如果我按了热键组合,它将起作用。

Now, i'm missing how to actually do what i want it to do: launch the extension's browser_action : open the popup.html (which is a search your bookmarks input field). 现在,我不知道如何实际执行我想做的事情:启动扩展程序的browser_action:打开popup.html(这是对您的书签输入字段的搜索)。 I've been looking for a method like chrome.trigger('browserAction'); 我一直在寻找像chrome.trigger('browserAction');这样的方法chrome.trigger('browserAction'); Perhaps i'm missing something really obvious... 也许我缺少真正明显的东西...

my background.js 我的background.js

chrome.commands.onCommand.addListener(function(command) {
  alert('Command:'+ command);
});

manifest.json (extract) manifest.json(解压缩)

  "commands": {
    "browser_action": {
      "suggested_key": {
        "default": "Ctrl+Shift+U",
        "mac": "Alt+Shift+U"
      },
      "description": "Opens the extension"
    }
  },
  "browser_action": {
      "default_title": "YURLS",
      "default_icon": "icon16.png",
      "default_popup": "popup.html"
  },

ah. 啊。 Simply changing the command name to the magic word _execute_browser_action in the manifest.json file did the trick. 只需将清单名称更改为manifest.json文件中的魔术词_execute_browser_action

"commands": {
    "_execute_browser_action": {
      "suggested_key": {
        "default": "Ctrl+Shift+U",
        "mac": "Alt+Shift+U"
      },
      "description": "Opens Yurl"
    }
  }

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

相关问题 Chrome扩展程序browser_action表单 - Chrome Extension browser_action form Chrome扩展程序从后台脚本启动browser_action弹出窗口 - Chrome extension initiate browser_action popup from background scripts 在 Chrome 扩展程序中,如何使用 browser_action (popup.html) 获取网站的 URL? - In a Chrome extension, how do I get the URL of the website with browser_action (popup.html)? page_action click 不起作用而 browser_action click 在 Chrome 扩展程序中工作? - page_action click does not work while browser_action click works in Chrome Extension? 如何在Chrome扩展程序中的浏览器操作上将Unicode字符设置为徽章文字? - How to set Unicode character as badge text on browser action in Chrome extension? Google Chrome扩展程序:将用户突出显示的网页文本传递给browser_action - Google Chrome Extensions: Passing user highlighted webpage text to a browser_action 点击时的browser_action行为。 它重新加载我的popup.html并删除sessionStorage - browser_action behaviour on click. It reloads my popup.html and deletes sessionStorage 使用浏览器操作Chrome扩展程序 - Using Browser Action Chrome Extension 浏览器启动时的 Chrome 扩展操作 - Chrome Extension Action on Browser Start 为什么我的 Chrome 扩展程序的浏览器操作弹出窗口不显示? - Why does my Chrome extension's browser action popup not show?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM