简体   繁体   English

Chrome扩展程序从后台脚本启动browser_action弹出窗口

[英]Chrome extension initiate browser_action popup from background scripts

I am trying to show a chrome extension popup from a trigger to shortcut keys like(ctrl+shift+U). 我正在尝试显示从触发器到快捷键之类的chrome扩展弹出窗口,例如(ctrl + shift + U)。

Manifest Json: 清单Json:

 "commands": {

    "generate_link": {
      "suggested_key": {
        "default": "Ctrl+K",
        "mac": "Command+K"
      },
      "description": "Builds link copy to extension."
    },


    "show-interface": {
      "suggested_key": {
        "default": "Ctrl+Shift+K",
        "mac": "Command+Shift+K"
      },
      "description": "Show builder interface2."
    }

Background script: 后台脚本:

chrome.commands.onCommand.addListener(function(command) {

    chrome.tabs.update({}, function(tab) {
    if (command == 'generate_link')
    {
       //need to show extension window with some info about the current tab
        getLink(tablink)
    }
    else if (command == 'show-interface')
          alert('show-interface');
  });
});

Is there any function that could trigger the same task that happens when we click on browser_action icon. 是否有任何功能可以触发与我们单击browser_action图标时发生的任务相同的任务。

This could be simple but new to chrome extensions and terminology, didn't find any good references for this kind of problem. 这可能很简单,但对于chrome扩展名和术语来说是新的,没有找到有关此类问题的良好参考。

Try adding "global": true . 尝试添加"global": true Here's a reference for chrome commands: https://developer.chrome.com/extensions/commands 这是chrome命令的参考: https : //developer.chrome.com/extensions/commands

Actually found it, this in command section is used to trigger the chrome extension open from shortcut. 实际上在命令部分找到了它,用于触发从快捷方式打开的chrome扩展。

"_execute_browser_action": {
      "suggested_key": {
        "default": "Ctrl+Shift+K",
        "mac": "Command+Shift+K"
      }

It was a misunderstanding of terminologies. 这是对术语的误解。 Thanks. 谢谢。

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

相关问题 Chrome扩展程序browser_action表单 - Chrome Extension browser_action form 在 Chrome 扩展程序中,如何使用 browser_action (popup.html) 获取网站的 URL? - In a Chrome extension, how do I get the URL of the website with browser_action (popup.html)? 如何设置将快捷键关联到我的Chrome扩展程序browser_action? - how to set associate a hotkey to my chrome extension browser_action? 将变量从“浏览器操作”发送到“内容脚本” - Send variables from “browser_action” to “content_scripts” page_action click 不起作用而 browser_action click 在 Chrome 扩展程序中工作? - page_action click does not work while browser_action click works in Chrome Extension? 如何防止browser_action每次重新加载其弹出窗口? - How to prevent browser_action from reloading its popup window every time? 将browser_action按钮变成快捷链接而不是弹出窗口 - Turn browser_action button into shortcut link instead of popup Chrome扩展程序中的数据未从弹出窗口传递到后台 - Data not passing from popup to background in chrome extension Chrome扩展程序:如何处理browser_action.default_popup DOM - Chrome Extension: How to manipulate browser_action.default_popup DOM 为什么 jQuery 在谷歌浏览器扩展的浏览器操作弹出窗口中不起作用? - Why is jQuery not working in the browser action popup of a google chrome extension?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM