Greasy Fork 还支持 简体中文。

Observe

Observe and wait for elements

目前為 2025-10-13 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/552301/1676521/Observe.js

作者
tukars
版本
2.1.2
建立日期
2025-10-11
更新日期
2025-10-13
尺寸
3.8 KB
授權條款
MIT

Observe functionality. Track when objects are added, do some functionality, wait for objects to be added. Some logging functionality. Example use:

const Observe = window.userscript.com.tukars.Observe;
const { log, warn, error, info, debug } = Observe.contextPrint(
  "My extension", ENABLE_DEBUG_LOGGING
);

log("Hello from my extension");

function handleInterruptionNotification(notification) {
  // do your thing here
}

(function () {
  "use strict";

  log("Interruptions remover script is active.");

  const popupContainerSelector = "ytd-popup-container.style-scope.ytd-app";

  const popupContainer = await waitForElement(popupContainerSelector);
  info("Found popup container. Attaching observer.", popupContainer);

  const notificationTags = ["yt-notification-action-renderer"];
  Observe.observeAndHandle(
    popupContainer,
    notificationTags,
    handleInterruptionNotification,
  );
})();