JavaScript – RTK-GNSS
let target = null;
function waitAsync(conditionCallback, resolve,intervalMilliSecond = 500){
if(conditionCallback()){
resolve();
return;
}
const intervalId = setInterval(()=>{
if(!conditionCallback()){
return;
}
clearInterval(intervalId);
resolve();
}, intervalMilliSecond)
}
const observer = new MutationObserver(records => {
console.log("TEST");
});
waitAsync(
() => {
target = document.querySelector('ul[id="item-grid"]');
return target !== null;
},
() => {
observer.observe(target, {childList: true});
console.log('ok');
}
);
2`target`
function add_ul() {
const ul = document.createElement('ul');
ul.id = 'item-grid';
document.body.appendChild(ul);
}
setTimeout( () => add_ul(), 2000 );
`"ok"`