Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

955 B
Raw Blame
const DEFAULT_FAVICON_PATH = '/logo.png';
const UNREAD_FAVICON_PATH = '/logo-unread.png';
const FAVICON_SELECTOR = 'link[rel="icon"]';
const BASE_HREF_ATTRIBUTE = 'data-avibe-base-href';

/** Keep the recognizable brand favicon and add only the unread-state red dot. */
export function syncFaviconBadge(
  count: number,
  targetDocument: Document | null = typeof document === 'undefined' ? null : document,
): void {
  if (!targetDocument) return;

  let link = targetDocument.querySelector<HTMLLinkElement>(FAVICON_SELECTOR);
  if (!link) {
    link = targetDocument.createElement('link');
    link.rel = 'icon';
    link.type = 'image/png';
    link.href = DEFAULT_FAVICON_PATH;
    targetDocument.head?.appendChild(link);
  }

  const baseHref = link.getAttribute(BASE_HREF_ATTRIBUTE) || link.getAttribute('href') || DEFAULT_FAVICON_PATH;
  link.setAttribute(BASE_HREF_ATTRIBUTE, baseHref);
  link.href = count > 0 ? UNREAD_FAVICON_PATH : baseHref;
}