// strip-icons.js — the sidebar web apps' icons and the well-known apps, // shared by the strip (quicklinks.html) and Settings › Sidebar (settings.html) // so both always show the same mark for a link. "use strict"; (function () { // Bundled brand marks. Each SVG is tight (20×20 viewBox, no padding), the // colour is baked in so icons read at a glance in both themes. Unknown ids // fall back to a letter chip. All marks are purely to identify services. const BRAND = { x: '', twitter: '', telegram: '', whatsapp: '', messenger: '', youtube: '', // Proton Mail: an envelope in Proton's purple. proton: '', spotify: '', discord: '', }; function brandFor(id) { return BRAND[String(id || "").toLowerCase()] || null; } // A link added by hand gets an id like "youtube-k3f9", so the mark is also // found by the site's address. const HOST_BRAND = [ [/(^|\.)(x|twitter)\.com$/, "x"], [/(^|\.)telegram\.org$/, "telegram"], [/(^|\.)whatsapp\.com$/, "whatsapp"], [/(^|\.)messenger\.com$/, "messenger"], [/(^|\.)(youtube\.com|youtu\.be)$/, "youtube"], [/(^|\.)spotify\.com$/, "spotify"], [/(^|\.)discord(app)?\.(com|gg)$/, "discord"], [/(^|\.)(proton\.me|protonmail\.com)$/, "proton"], ]; const hostOf = (url) => { try { return new URL(url).hostname.toLowerCase(); } catch { return ""; } }; function brandForLink(L) { const byId = brandFor(L.id); if (byId) return byId; const h = hostOf(L.url); for (const [re, key] of HOST_BRAND) if (re.test(h)) return BRAND[key]; return null; } // Any other site: its own favicon, and the first letter if it has none. // Well-known web apps: what Settings › Sidebar suggests as you type a title // or an address (→ accepts the grey rest of the suggestion). const KNOWN = [ { title: "Proton Mail", url: "https://mail.proton.me/" }, { title: "Telegram", url: "https://web.telegram.org/k/" }, { title: "WhatsApp", url: "https://web.whatsapp.com/" }, { title: "X", url: "https://x.com/" }, { title: "YouTube", url: "https://www.youtube.com/" }, { title: "Discord", url: "https://discord.com/app" }, { title: "Messenger", url: "https://www.messenger.com/" }, { title: "Spotify", url: "https://open.spotify.com/" }, ]; // The markup for a link, or null when it has no bundled mark. function svgFor(L) { return brandForLink(L || {}); } window.StripIcons = { BRAND, svgFor, hostOf, KNOWN }; })();