Estoy tratando de cambiar el ícono de la extensión según lo que se encuentre en la URL, lo siguiente funciona pero aparece un error:
No detectado (en promesa) TypeError: failCallback no es una función Extensiones de contexto::setIcon Stack Trace
Estoy seguro de que esto es un bosque para los árboles. ¿Alguien puede ayudar?
//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 }) };El error está en extensions::setIcon:35, que es la línea que comienza con "fallo", aquí:
$Promise.catch(imageDataPromise, function(error) { failureCallback(exceptionHandler.safeErrorToString(error, true)); });Es un error en Chromium .
Sugiere una ruta de archivo no válida. Pero funciona.