Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
Chrome extension action.onClicked

I am building a chrome extension and I use this code to open the popup in new window. (Using manifest v3) It suddenly stopped working today.

Uncaught TypeError: Cannot read properties of undefined (reading 'onClicked') Yesterday it worked just fine and it corresponds with chrome extension documentation. Anyone knows what the issue could be?

Here is my code:

chrome.action.onClicked.addListener(tab => {
    chrome.windows.create({
        url: chrome.runtime.getURL("popup.html"),
        type: "popup",
        height: 800,
        width: 516
      }, function(win) {
      });
});
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Thanks @woxxom. I have deleted action from the manifest. Didn't realize it's needed for the chrome.action to work. Fixed.

about 4 years ago · Juan Pablo Isaza Relatório

0

This question was already answered, but I wanted to post a full example since I couldn't find a post that had both extension code and corresponding manifest.json.

Here is full, valid example using Manifest V3.

// File: manifest.json //

{
    "manifest_version": 3,
    "name": "My extension",
    "description": "Extension that extends things",
    "author": "Me",
    "version": "0.1",
    "content_scripts": [
      {
        "matches": [
          "https://*"
        ],
        "js": ["content.js"]
      }
    ],
    "icons": { "48":  "icons/icon128.jpg",
              "128":  "icons/icon512.jpg"},
    "background": {
      "service_worker": "background.js"
    },
    "action": {},
    "permissions": [
      "storage",
      "downloads",
      "tabs"
  ]
}
// File: background.js //

// Called when the user clicks on the browser action.
chrome.action.onClicked.addListener(tab => {
    // Send a message to the active tab
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
      var activeTab = tabs[0];
      chrome.tabs.sendMessage(activeTab.id, {"message": "clicked_browser_action"});
    });
  });

(Obviously remove the comment from the .json file before copying it, and adjust the permissions of your extension appropriately.)

Note that if you're using a version of Chrome below Chrome 93, your manifest.json and background.js must be in the SAME directory.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda