import { preferences } from "@/utils/storage"; import config from "@/utils/config.json"; import * as view from "./view"; import { pullKVCache } from "@/utils/utilities"; export default defineContentScript({ matches: ['*://polytoria.com/u/*', '*://polytoria.com/users/*'], main() { 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 (!config.api.enabled) return "disabled"; const data = (await (await fetch(config.api.urls.public + "users/find?username=" + username)).json()); return data.id; }, 600000, false ); } else { userID = username; // * Fallback for legacy profile URLs } if (window.location.pathname.split('/')[1] == "u") { // View view.displayId(userID); }; }); } });