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( 22 config.api.urls.public + "users/find?username=" + username, 23 )).json(); 24 return data.id; 25 }, 26 -1, 27 false, 28 ); 29 } else { 30 userID = username; // * Fallback for legacy profile URLs 31 } 32 33 if (window.location.pathname.split("/")[1] == "u") { 34 // View 35 if (config.devBuild) { 36 console.log("[Poly+] Running view page functions: ", view); 37 } 38 39 view.displayId(userID); 40 if (values.outfitCost.enabled) view.outfitCost(userID); 41 } 42 }); 43 }, 44});