소스 검색

feat: add selectorobserver instance "bytmDialogContainer"

Sv443 7 달 전
부모
커밋
b688188362
1개의 변경된 파일15개의 추가작업 그리고 1개의 파일을 삭제
  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