Sfoglia il codice sorgente

feat: add selectorobserver instance "bytmDialogContainer"

Sv443 7 mesi fa
parent
commit
b688188362
1 ha cambiato i file con 15 aggiunte e 1 eliminazioni
  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