A rewrite of Poly+, my quality-of-life browser extension for Polytoria. Built entirely fresh using the WXT extension framework, Typescript, and with added better overall code quality.
extension
1import { preferences } from "@/utils/storage"; 2import config from "@/utils/config.json"; 3import * as view from "./view"; 4import { pullKVCache } from "@/utils/utilities"; 5 6export default defineContentScript({ 7 matches: ['*://polytoria.com/u/*', '*://polytoria.com/users/*'], 8 main() { 9 preferences.getPreferences() 10 .then(async (values) => { 11 let userID; 12 const username = window.location.pathname.split('/')[2]; 13 14 if (isNaN(username as any)) { 15 userID = await pullKVCache( 16 'userIDs', 17 username, 18 async () => { 19 if (!config.api.enabled) return "disabled"; 20 21 const data = (await (await fetch(config.api.urls.public + "users/find?username=" + username)).json()); 22 return data.id; 23 }, 24 600000, 25 false 26 ); 27 } else { 28 userID = username; // * Fallback for legacy profile URLs 29 } 30 31 if (window.location.pathname.split('/')[1] == "u") { 32 // View 33 view.displayId(userID); 34 }; 35 }); 36 } 37});