(function () { const clients = [ { name: "Bluesky", base: "https://bsky.app/profile/", icon: "https://imrs.madebydanny.uk?url=https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/bsky.webp", cls: "bsky" }, { name: "Blacksky", base: "https://blacksky.community/profile/", icon: "https://imrs.madebydanny.uk?url=https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/blacksky.webp", cls: "blacksky" }, { name: "Anisota", base: "https://anisota.net/profile/", icon: "https://imrs.madebydanny.uk?url=https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/anissota.webp", cls: "anisota" }, { name: "Deer Social", base: "https://deer.social/profile/", icon: "https://imrs.madebydanny.uk?url=https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/deer.webp", cls: "deer" }, { name: "Catsky", base: "https://catsky.social/profile/", icon: "https://imrs.madebydanny.uk?url=https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/catsky.webp", cls: "catsky" }, { name: "Witchsky", base: "https://witchsky.app/profile/", icon: "https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/bitchsky.svg", cls: "bitch" }, { name: "kibun", base: "https://www.kibun.social/users/", icon: "https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/kibun.ico", cls: "bsky" }, { name: "plyr.fm", base: "https://plyr.fm/u/", icon: "https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/plyr.ico", cls: "bsky" }, { name: "Nooki", base: "https://nooki.me/user/", icon: "https://imrs.madebydanny.uk?url=https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/nooki.webp", cls: "nooki" }, { name: "Tangled", base: "https://tangled.org/", icon: "https://imrs.madebydanny.uk?url=https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/tangled.webp", cls: "tangled" }, { name: "Stream Place", base: "https://stream.place/", icon: "https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/splace.ico", cls: "splace" }, { name: "PDSls", base: "https://pdsls.dev/at://", icon: "https://imrs.madebydanny.uk?url=https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/pdsls.webp", cls: "bsky" }, { name: "Red Dwarf", base: "https://reddwarf.app/profile/", icon: "https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/redd.ico", cls: "redd" }, { name: "Deer (aylac fork)", base: "https://deer.aylac.top/profile/", icon: "https://imrs.madebydanny.uk?url=https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/aylac.webp", cls: "deer" }, { name: "Semble", base: "https://semble.so/user/", icon: "https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/semble.svg", cls: "semble" }, { name: "Sky Space", base: "https://skyspace.me/?", icon: "https://imrs.madebydanny.uk?url=https://cloudflareisawesome.madebydanny.uk/madebydanny.uk/followonbsky/skyspace.jpg", cls: "skyspace" }, ]; const avatarEl = document.getElementById('avatar'); const nameEl = document.getElementById('displayName'); const tagEl = document.getElementById('tagline'); const linksRoot = document.getElementById('links'); const moreClientsRoot = document.getElementById('more-clients'); const showMoreBtn = document.getElementById('show-more'); const tryInput = document.getElementById('try-handle'); const tryBtn = document.getElementById('try-button'); const customInput = document.getElementById('custom-client'); const customBtn = document.getElementById('custom-open'); function setText(el, txt){ el.textContent = txt ?? ''; } function makeClientLink(c, handle){ const a = document.createElement('a'); a.className = 'link ' + (c.cls || ''); a.href = c.base + encodeURIComponent(handle); a.target = '_blank'; a.rel = 'noopener'; a.setAttribute('aria-label', `Open ${c.name} for ${handle}`); const img = document.createElement('img'); img.src = c.icon; img.alt = c.name + ' icon'; img.loading = 'lazy'; const span = document.createElement('span'); span.className = 'label'; span.textContent = c.name; a.append(img, span); return a; } function openCustom(handle){ let url = (customInput.value || '').trim(); if(!url)return; if(!/^https?:\/\//i.test(url))url='https://'+url; url=url.replace(/\/+$/,'')+'/profile/'+encodeURIComponent(handle); window.open(url,'_blank','noopener'); } function tryProfile() { let value = (tryInput.value || '').trim(); if (!value) return; if (value.startsWith('@')) value = value.slice(1); try { const parsed = new URL(value); const parts = parsed.pathname.split('/').filter(Boolean); if (parts.length && (parts[0] === 'profile' || parts[0] === 'actor')) { value = parts[1]; } } catch (_) { } const u = new URL(location.href); u.searchParams.set('did', value); location.href = u.toString(); } async function loadProfile(){ const params=new URLSearchParams(location.search); const did=params.get('did'); if(!did){ setText(nameEl,'Missing ?did='); setText(tagEl,'Add a DID or handle to view a profile.'); tryBtn.onclick=tryProfile; tryInput.onkeydown=e=>{if(e.key==='Enter')tryProfile()}; return; } try{ const res=await fetch(`https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(did)}`); if(!res.ok)throw new Error('fetch failed'); const data=await res.json(); const handle=data.handle||did; const avatar=data.avatar?`https://imrs.madebydanny.uk?url=${encodeURIComponent(data.avatar)}`:'https://imrs.madebydanny.uk/?url=https://public-cdn.madebydanny.uk/user-content/2025-10-11/1760220038748_cloudflare-brands-solid-full.svg'; avatarEl.src=avatar; avatarEl.alt=`${data.displayName||handle} avatar`; setText(nameEl,data.displayName||handle); setText(tagEl,`@${handle} is on the AT Protocol – pick a client to follow them!`); linksRoot.innerHTML=''; moreClientsRoot.innerHTML=''; const topClients = clients.slice(0, 6); const moreClients = clients.slice(6); topClients.forEach(c=>linksRoot.appendChild(makeClientLink(c,handle))); moreClients.forEach(c=>moreClientsRoot.appendChild(makeClientLink(c,handle))); if(moreClients.length > 0){ showMoreBtn.style.display = 'block'; showMoreBtn.onclick = function(){ moreClientsRoot.classList.toggle('show'); this.textContent = moreClientsRoot.classList.contains('show') ? 'Show Less' : 'Show More Clients'; }; } customBtn.onclick=()=>openCustom(handle); customInput.onkeydown=e=>{if(e.key==='Enter')openCustom(handle)}; tryBtn.onclick=tryProfile; tryInput.onkeydown=e=>{if(e.key==='Enter')tryProfile()}; }catch(e){ nameEl.textContent='Error loading profile'; tagEl.textContent='Check your DID or try again.'; linksRoot.innerHTML=''; moreClientsRoot.innerHTML=''; showMoreBtn.style.display = 'none'; tryBtn.onclick=tryProfile; tryInput.onkeydown=e=>{if(e.key==='Enter')tryProfile()}; } } document.addEventListener('DOMContentLoaded',loadProfile); })();