Browse Source

feat: add selectorobserver instance "bytmDialogContainer"

Sv443 7 months ago
parent
commit
b688188362
1 changed files with 15 additions and 1 deletions
  1. 15 1
      src/observers.ts

+ 15 - 1
src/observers.ts

@@ -18,7 +18,8 @@ export type ObserverNameByDomain<TDomain extends Domain> = SharedObserverName |
 
 // Shared between YTM and YT
 export type SharedObserverName =
-  | "body"; // the entire <body> element
+  | "body"                 // the entire <body> element
+  | "bytmDialogContainer"; // the container for all BytmDialog instances
 
 // YTM only
 export type YTMObserverName =
@@ -111,6 +112,19 @@ export function initObservers() {
 
     globservers.body.enable();
 
+    //#region bytmDialogContainer
+    // -> the container for all BytmDialog instances
+    //    enabled immediately
+    const bytmDialogContainerSelector = "#bytm-dialog-container";
+    globservers.bytmDialogContainer = new SelectorObserver(bytmDialogContainerSelector, {
+      ...defaultObserverOptions,
+      defaultDebounceEdge: "falling",
+      defaultDebounce: 100,
+      subtree: true,
+    });
+
+    globservers.bytmDialogContainer.enable();
+
     switch(getDomain()) {
     case "ytm": {
       //#region YTM