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

182
Visualizações
chrome.action.setIcon failureCallback is not a function

I'm trying to change the extension icon depending on what is found in the URL, the below works but i get an error:

Uncaught (in promise) TypeError: failureCallback is not a function Context extensions::setIcon Stack Trace

I feel sure this is a woods for the trees thing. Can anyone help?

//get url of the page we are on in the tab
async function getTab() {
  let queryOptions = { active: true, currentWindow: true };
  let tabs = await chrome.tabs.query(queryOptions);
  return tabs[0];
};
                
var tab;
                
//listen for the following two events - when they happen run the colourIcon function
chrome.tabs.onActivated.addListener(colourIcon);
chrome.tabs.onUpdated.addListener(colourIcon);
                
async function colourIcon(){
  let urlCol = await getTab()
  let url = urlCol.url
  tab = urlCol.id
  if (url.indexOf("d") > -1) {
    changeIconColour("purple");
  } else if (url.indexOf("b") > -1) {
    changeIconColour("purple");
  } else if (url.indexOf("a") > -1) {
    changeIconColour("purple");
  } else { // if there is no match, you can't get the data
    changeIconColour("grey");
  };
}
            
function changeIconColour(colour) {
  let pathToIcons;
  //change the path to the icon folder depending on what colour is sent to the function
  if (colour == "purple") {
    pathToIcons = "/";
  } else {
    pathToIcons = "grey/";
  }
            
  // and set the icon
  chrome.action.setIcon({
    path: {
      "16": "/assets/icons" + pathToIcons + "extension_toolbar_icon16.png",
      "32": "/assets/icons" + pathToIcons + "extension_toolbar_icon32.png",
      "48": "/assets/icons" + pathToIcons + "extension_toolbar_icon48.png",
      "128": "/assets/icons" + pathToIcons + "extension_toolbar_icon128.png"
    },
    tabId: tab
    })
  };

The error is at extensions::setIcon:35, which is the line starting "failure", here:

$Promise.catch(imageDataPromise, function(error) {
    failureCallback(exceptionHandler.safeErrorToString(error, true));
  });
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It's a bug in Chromium.

Suggests an invalid filepath. But it works.

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