1const targetNode = document.body;
2const config = { childList: true, subtree: true };
3
4const callback = function(mutationsList, observer) {
5 for(let mutation of mutationsList) {
6 if (mutation.type === 'childList') {
7 // Elements have changed
8 }
9 }
10};
11
12const observer = new MutationObserver(callback);
13observer.observe(targetNode, config);