A small wrapper around MutationObserver to hook into creation of elements based on a CSS selector.
Version vom
Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @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
});
}