← Commit history

v2.0.568 (insiders): Overlay badge composed in the binary for both lanes; ext windows branded before first show.

John Lauer ·b808a639ba ·1mo ago ·parent c8a6692
1 file changed +23
src/extension/worker.js+23
@@ -216,6 +216,29 @@ async function pupExtPoll() {         args: [cmd.expr || ''],       });       out = { id: cmd.id, ok: true, result: res && res[0] && res[0].result, tabId: tab.id, windowId: tab.windowId, url: tab.url };+    } else if (cmd.action === 'favicon') {+      // The active tab's declared icons, read by an INJECTED FUNCTION (page CSP cannot refuse it, unlike+      // eval), fetched from the extension's own context, handed to the bridge which composes the badge.+      const tab = await pupExtTab(cmd);+      let hrefs = [];+      try {+        const res = await chrome.scripting.executeScript({ target: { tabId: tab.id }, world: 'ISOLATED', func: () => {+          const out = [];+          for (const l of document.querySelectorAll('link[rel~="icon"], link[rel="shortcut icon"], link[rel="apple-touch-icon"]')) { if (l.href && !l.href.startsWith('blob:')) out.push(l.href); }+          return out; } });+        hrefs = (res && res[0] && res[0].result) || [];+      } catch (e) {}+      let favicon = null;+      for (const h of hrefs) {+        try {+          const r = await fetch(h, { credentials: 'include' }); if (!r.ok) continue;+          const b = await r.blob(); if (!b.size) continue;+          const buf = new Uint8Array(await b.arrayBuffer()); let bin = ''; const CH = 8192;+          for (let i = 0; i < buf.length; i += CH) bin += String.fromCharCode.apply(null, buf.subarray(i, Math.min(i + CH, buf.length)));+          favicon = { href: h, type: b.type || '', b64: btoa(bin) }; break;+        } catch (e) {}+      }+      out = { id: cmd.id, ok: true, hrefs, favicon, url: tab.url };     } else if (cmd.action === 'newtab') {       // a TAB in the SAME window: the channel could only create new WINDOWS, so it could not show many       // pages in one window the way the CDP lane does.