refactor: moved components to separate modules

`content.ts` is now half less than the size, exported functions can be unit tested
This commit is contained in:
xenticore
2025-03-24 15:39:28 -04:00
parent 493e7b6521
commit 12de4a7148
9 changed files with 326 additions and 351 deletions

9
src/content/utils/dom.ts Normal file
View File

@@ -0,0 +1,9 @@
export function findFirstElement(selector: string): HTMLElement | null {
const elements = document.querySelectorAll(selector);
return elements.length > 0 ? elements[0] as HTMLElement : null;
}
export function findFirstChildElement(selector: string, root: Element): HTMLElement | null {
const elements = root.querySelectorAll(selector);
return elements.length > 0 ? elements[0] as HTMLElement : null;
}