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 config from "./config.json"; 2import { userApiSchema, placeApiSchema } from "./types"; 3 4const users: { 5 batch?: (ids: string[]) => Promise<Record<string, userApiSchema>> 6} = {}; 7 8const places: { 9 batch?: (ids: string[]) => Promise<Record<string, placeApiSchema>> 10} = {}; 11 12users.batch = async (ids: string[]): Promise<Record<string, userApiSchema>> => { 13 const res: Record<string, userApiSchema> = {}; 14 for (let id of ids) { 15 const info = await (await fetch(config.api.url + '/users/' + id)).json(); 16 res[id] = info; 17 } 18 return res; 19}; 20 21places.batch = async (ids: string[]): Promise<Record<string, placeApiSchema>> => { 22 const res: Record<string, placeApiSchema> = {}; 23 for (let id of ids) { 24 const info = await (await fetch(config.api.url + '/places/' + id)).json(); 25 res[id] = info; 26 } 27 return res; 28}; 29 30export default { 31 users: users, 32 places: places 33};