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 { bricksToCurrency } from "@/utils/utilities"; 2 3export function irlBrickPrice() { 4 const grid = document.getElementById('assets')!; 5 6 const addPrice = (item: HTMLElement) => { 7 const brickCount = item.getElementsByClassName('text-success')[0].textContent!; 8 const currency = bricksToCurrency(parseInt(brickCount), "USD"); 9 10 if (currency) { 11 const spanTag = document.createElement('span'); 12 spanTag.classList.add('text-muted'); 13 spanTag.style.fontSize = '0.7rem'; 14 spanTag.style.fontWeight = 'lighter'; 15 spanTag.innerText = ` (${currency})`; 16 item.getElementsByClassName('text-success')[0].appendChild(spanTag); 17 }; 18 }; 19 20 for (const item of document.getElementsByClassName('itemCardCont')) { 21 addPrice(item as HTMLElement); 22 }; 23 24 const mutations = new MutationObserver((mutations) => { 25 for (const record of mutations) { 26 for (const node of record.addedNodes) { 27 const item = node as HTMLElement; 28 if ((item as HTMLElement).classList.contains('itemCardCont')) addPrice(item); 29 }; 30 }; 31 }); 32 33 mutations.observe(grid, { childList: true }); 34}