Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
Chrome Extension open popup by command

I want to use a shortcut Ctrl + B to open popup.html of my extension, so I don't need to move the mouse and click.

I tried the commands config from Google document but it seems doesn't work. Does anyone know how to fix this? Below is my configuration (Note that I'm using manifest_version: 3)

manifest.json:

{
  "name": "",
  "description": "",
  "version": "0.0.1",
  "manifest_version": 3,
  "background": {
    "service_worker": "background.js"
  },
  "action": {
    "default_popup": "popup.html"
  },
"commands": {
    "_execute_action": {
      "suggested_key": {
        "default": "Ctrl+B",
        "mac": "Ctrl+B"
      }
    }
  }
}

popup.html

<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  Hello world
</body>
</html>

background.js

// Currently empty
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Don't know if this works for you, but if position of popup.html is not an issue for you this shall work if added to your background.js script. (executed on local host in manifest version 3)

manifest.json

 "commands": {
 "my_shortcut": {
  "suggested_key": {
    "default": "Ctrl+B",
    "mac": "Command+B"
  },
  "description": "Opens popup.html",
  "global": true
},
}

background.js

chrome.commands.onCommand.addListener((command) => {

if (command === 'my_shortcut')
    chrome.system.display.getInfo({ singleUnified: true }, (info) => {
    
      const wDimension = info[0].workArea;
      const { top, left, height, width } = wDimension;
      console.log(top);
      const w = 440;
      const h = 220;
      const l = width / 2 - w / 2 + left;
      const t = height / 2 - h / 2 + top;
      const newWindow = () => {
        console.log('in new window function');
      };
      chrome.windows.create(
        {
          url: 'popup.html',
          type: 'popup',
          width: w,
          height: h,
          left: Math.round(l),
          top: Math.round(t),
        },
        newWindow
      );
    });
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda