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 { getUserDetails, bricksToCurrency } from "@/utils/utilities";
3
4export default defineContentScript({
5 matches: ['*://polytoria.com/*'],
6 main() {
7 getUserDetails()
8 .then((user) => {
9 if (!user) {
10 // Error page or event page most likely, where users are not authenticated
11 console.warn('[Poly+] Failure to get logged in user details.');
12 return;
13 };
14
15 preferences.getPreferences()
16 .then((values) => {
17 if (values.irlBrickPrice.enabled) {
18 const currency = bricksToCurrency(user.bricks, "USD");
19 if (currency) document.getElementsByClassName('brickBalanceCount')[0].textContent += ` (${currency})`;
20 };
21 });
22 });
23 }
24});