Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

fix: use most common domain, gstatic favicon API, shared utils

Luis Ortiz496863988f88
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 7d82fc4..29c363e 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -29,9 +29,27 @@ export function extractDomain(url: string): string {
}
}
-export function getFaviconUrl(url: string): string {
+export function getMostCommonDomain(steps: { url?: string | null }[]): string {
+ const counts = new Map<string, number>();
+ for (const s of steps) {
+ const d = extractDomain(s.url || '');
+ if (d) counts.set(d, (counts.get(d) || 0) + 1);
+ }
+ let best = '';
+ let max = 0;
+ for (const [d, c] of counts) {
+ if (c > max) {
+ max = c;
+ best = d;
+ }
+ }
+ return best;
+}
+
+export function getFaviconUrl(url: string, size = 64): string {
try {
- return `https://www.google.com/s2/favicons?domain=${new URL(url).hostname}&sz=32`;
+ const full = /^https?:\/\//i.test(url) ? url : `https://${url}`;
+ return `https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=${encodeURIComponent(full)}&size=${size}&drop_404_icon=true`;
} catch {
return '';
}
diff --git a/src/ui/sidepanel/GuideEditor.tsx b/src/ui/sidepanel/GuideEditor.tsx
index 67421fe..8320b29 100644
--- a/src/ui/sidepanel/GuideEditor.tsx
+++ b/src/ui/sidepanel/GuideEditor.tsx
@@ -10,6 +10,7 @@ import {
} from '@/core/guides/service';
import type { Guide, Screenshot, Step } from '@/core/guides/types';
import { createTab, focusWindow, getExtensionURL, queryTabs, updateTab } from '@/lib/browser-api';
+import { getFaviconUrl, getMostCommonDomain } from '@/lib/utils';
import { Input } from '@/ui/components/ui/input';
import BlurCanvas from './BlurCanvas';
import ExportMenu from './ExportMenu';
@@ -155,10 +156,30 @@ export default function GuideEditor({ guideId, onBack }: GuideEditorProps) {
<ExportMenu guideId={guideId} guide={data.guide} steps={data.steps} screenshots={data.screenshots} />
</div>
</div>
- <p className="text-[11px] flex items-center gap-1 text-muted-foreground" style={{ marginLeft: '34px' }}>
- <Layers size={11} />
- {data.steps.length} step{data.steps.length !== 1 ? 's' : ''}
- </p>
+ <div className="text-[11px] flex items-center gap-2 text-muted-foreground" style={{ marginLeft: '34px' }}>
+ <span className="flex items-center gap-1">
+ <Layers size={11} />
+ {data.steps.length} step{data.steps.length !== 1 ? 's' : ''}
+ </span>
+ {(() => {
+ const d = getMostCommonDomain(data.steps);
+ if (!d) return null;
+ return (
+ <span className="flex items-center gap-1">
+ <span className="text-border">Β·</span>
+ <img
+ src={getFaviconUrl(d, 16)}
+ alt=""
+ className="w-3 h-3 rounded-full"
+ onError={(e) => {
+ (e.target as HTMLImageElement).style.display = 'none';
+ }}
+ />
+ {d}
+ </span>
+ );
+ })()}
+ </div>
</div>
<div className="px-4 pt-1 pb-4">
{data.steps.length === 0 ? (