import { preferences } from "@/utils/storage"; import config from "@/utils/config.json"; import * as view from "./view"; import { pullKVCache } from "@/utils/utilities"; import { getAPI } from "@/utils/api"; export default defineContentScript({ matches: ["*://polytoria.com/u/*", "*://polytoria.com/users/*"], main() { const publicAPI = getAPI("public"); preferences.getPreferences() .then(async (values) => { let userID; const username = window.location.pathname.split("/")[2]; if (isNaN(username as any)) { userID = await pullKVCache( "userIDs", username, async () => { if (!publicAPI.enabled) return "disabled"; const data = await (await fetch( publicAPI.url + "users/find?username=" + username, )).json(); return data.id; }, -1, false, ); } else { userID = username; // * Fallback for legacy profile URLs } if (window.location.pathname.split("/")[1] == "u") { // View if (config.devBuild) { console.log("[Poly+] Running view page functions: ", view); } view.displayId(userID); if (values.enabled.includes("outfitCost")) view.outfitCost(userID); } }); }, });