In my Adobe Captivate script, I have set up automation on the first slide to create courses. The script generates UX, navigation elements, intro/end motions, a game, and inserts spritesheets with characters.
Previously, I used DOMNodeInserted to monitor modifications on the slide. Each time the user moved to the next slide, new elements were added to the DOM and the page content changed. I utilized a timer to call the function:
function detectChange(){
var slideName = document.getElementById('div_Slide')
slideName.addEventListener("DOMNodeInserted", detectChange, false);
updateSlideElements();
setTimeout(updateSlideElements, 100);
}
Now, I am exploring mutation Observer:
var observer = new MutationObserver(function(mutations, observer) {
updateSlideElements();
});
observer.observe(document.getElementById('div_Slide').firstChild, {
attributes: true,
childList:true
});
However, when using mutationObserver, I encounter an issue. Previously, with setTimeout, I could access the following element:
var motionText2 = document.querySelectorAll('div[id*=motion][class=cp-accessibility]');
This element is the firstChild of:
https://i.sstatic.net/9ebVU.png
And the element can be found at:
https://i.sstatic.net/0NmY1.png
But now, using mutationObserver, the console returns empty: