MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / setIcon

Function setIcon

src/background/utils/icon.js:211–231  ·  view source on GitHub ↗
({ id: tabId } = {}, data = badges[tabId] || {})

Source from the content-addressed store, hash-verified

209}
210
211async function setIcon({ id: tabId } = {}, data = badges[tabId] || {}) {
212 const mod = !isApplied ? 'w'
213 : data[INJECT] !== true ? 'b'
214 : '';
215 if (data.icon === mod) return;
216 data.icon = mod;
217 const pathData = {};
218 const iconData = {};
219 for (const n of SIZES) {
220 const url = `${ICON_PREFIX}${n}${mod}.png`;
221 pathData[n] = url;
222 iconData[n] = iconDataCache[url]
223 || await (iconCache[url] || (iconCache[url] = loadIcon(url))) && iconDataCache[url];
224 }
225 // imageData doesn't work in Firefox Android, so we also set path here
226 browserAction.setIcon({
227 tabId,
228 path: pathData,
229 imageData: iconData,
230 });
231}
232
233/** Omitting `data` = check whether injection is allowed for `url` */
234export function getFailureReason(url, data, def = titleDefault) {

Callers 2

icon.jsFile · 0.85
updateStateFunction · 0.85

Calls 1

loadIconFunction · 0.85

Tested by

no test coverage detected