diff options
Diffstat (limited to 'src/content/Bootstrap.ts')
-rw-r--r-- | src/content/Bootstrap.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/content/Bootstrap.ts b/src/content/Bootstrap.ts new file mode 100644 index 0000000..62e1530 --- /dev/null +++ b/src/content/Bootstrap.ts @@ -0,0 +1,27 @@ +type Callback = () => void; + +export default class Bootstrap { + constructor() {} + + isReady(): boolean { + return document.body !== null; + } + + waitForReady(callback: Callback): void { + const observer = new MutationObserver(() => { + if (document.body != null) { + observer.disconnect(); + callback(); + } + }); + + observer.observe(document, { + attributes: false, + attributeOldValue: false, + characterData: false, + characterDataOldValue: false, + childList: true, + subtree: true, + }); + } +} |