// ==UserScript==
// @name Genshin Map - Remove M.G. comments
// @match https://genshin-impact-map.appsample.com/*
// @run-at document-idle
// ==/UserScript==
(function () {
const TARGET_TEXT = "M.G.";
function removeCommentAncestor(div) {
const comment = div.closest('.Comment');
if (comment) comment.remove();
else div.remove();
}
function scan(root = document) {
root.querySelectorAll('div.d-flex').forEach(div => {
// normalizar espacios y evitar falsos positivos simples
if ((div.innerText || "").indexOf(TARGET_TEXT) !== -1) {
removeCommentAncestor(div);
}
});
}
// escaneo inicial
scan();
// observer para nodos añadidos dinámicamente
const obs = new MutationObserver(mutations => {
for (const m of mutations) {
for (const node of m.addedNodes) {
if (node.nodeType !== 1) continue;
// si el nodo añadido es el div objetivo
if (node.matches && node.matches('div.d-flex')) {
if ((node.innerText || "").indexOf(TARGET_TEXT) !== -1) removeCommentAncestor(node);
continue;
}
// si contiene hijos objetivo
scan(node);
}
}
});
obs.observe(document.body, { childList: true, subtree: true });
// fallback ligero: re-scan periódico por si el texto se carga después (opcional)
// const interval = setInterval(() => scan(), 2000);
// run once a while and uncomment the line above if you see misses
})();