A small wrapper around MutationObserver to hook into creation of elements based on a CSS selector.
이 스크립트는 직접 설치하는 용도가 아닙니다. 다른 스크립트에서 메타 지시문 // @require https://update.greasyfork.org/scripts/565361/1749989/Element%20Creation%20Hook.js을(를) 사용하여 포함하는 라이브러리입니다.
// ==UserScript==
// @name Element Creation Hook
// @namespace https://greasyfork.org/users/1545341
// @version 1.0.0
// @license MIT
// @author abcenjoyer
// @description A small wrapper around MutationObserver to hook into creation of elements based on a CSS selector.
// ==/UserScript==
function hookCreation(selector, callback) {
const observer = new MutationObserver((mutations) => {
const element = document.querySelector(selector);
if (element) {
callback(element);
observer.disconnect();
}
});
observer.observe(document.documentElement, {
childList: true,
subtree: true,
attributes: true,
characterData: true
});
}