Div 要素の変更を観察しています。これは、ajax 呼び出しを使用して子 div で満たされています。私の目的は、観察された Record オブジェクト内でいくつかのチェックを行い、それらのいくつかをフィルタリングすることです。観察されたミューテーション リストからこれらのミューテーション レコードを削除/削除/フィルタリングするにはどうすればよいですか? そしてそれらをウェブページでフィルタリングします。
ミューテーション リストからミューテーション レコードを削除しようとしましたが、うまくいきませんでした。ご協力いただきありがとうございます。
Array.prototype.remove = function() {
var what, a = arguments, L = a.length, ax;
while (L && this.length) {
what = a[--L];
while ((ax = this.indexOf(what)) !== -1) {
this.splice(ax, 1);
}
}
return this;
};
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
var addedNode = mutation.addedNodes[0];
if(addedNode){
var innText = addedNode.innerText;
//console.log("number " + i + " | " + addedNode.innerText);
if(innText){
if(innText.toLowerCase().indexOf(someText) > -1){
mutations.remove(mutation);
}
}
}
});
});
var config = {
attributes: true,
childList: true,
characterData: true,
characterDataOldValue: true,
subtree: true
};
observer.observe(text, config);