javascript:(async function(){ var url = new URL(window.location.href); var domain = url.hostname; var path = url.pathname; /* Check if it's a post (it has an ID at the end) */ var postMatch = path.match(/\/@[^\/]+\/(\d+)/); if (postMatch) { window.location.href = "https://phanpy.social/#/" + domain + "/s/" + postMatch[1]; return; } /* If it's a profile: Look up the ID via the API */ var profileMatch = path.match(/\/(@[^\/]+)/); if (profileMatch) { try { var response = await fetch("https://" + domain + "/api/v1/accounts/lookup?acct=" + profileMatch[1]); var data = await response.json(); if (data.id) { window.location.href = "https://phanpy.social/#/" + domain + "/a/" + data.id; } else { throw new Error(); } } catch (e) { /* Fallback to search if the API lookup fails */ window.location.href = "https://phanpy.social/#/search?q=" + encodeURIComponent(window.location.href); } } })();