Limit answer attempts and hide solution until max allowed attempts have been reached

Forums: 

I have added the following jQuery code to limit attempts to 3 times and to hide the solution until all three attempts have been executed:
(check_count is a variable in the main document that is counting the attempts and is initially set to 0)

H5P.jQuery('.h5p-question-try-again').add('.h5p-question-check-answer').bind("click", function(event) {
       if(parent.check_count < 2){
          parent.check_count++;
          H5P.jQuery('.h5p-question .h5p-joubelui-button.h5p-question-show-solution').hide();

       }else{
          H5P.jQuery('.h5p-question-check-answer').hide();
          H5P.jQuery('.h5p-question-try-again').hide();
          H5P.jQuery('.h5p-question .h5p-joubelui-button.h5p-question-show-solution').show();
       }
});


It works for Quiz (Question sets), but not for interactive videos. The dialogs are not loaded initially with the H5P video, but with the dialog when a question is loaded into the video. So how can I interact with those question buttons? Can I even interact with those through jQuery?

Summary: 
Limit attempts and hide solutions until attempts have been executed
Content types: 

Found the answer to my own question:
https://h5p.org/events
https://h5p.org/comment/20508#comment-20508

H5P.externalDispatcher.on('domChanged', function (event) {
	if (event.data.key === 'newLibrary' && event.data.library !== 'H5P.InteractiveVideo' ) {
		event.data.$target[0].children[2].children[0].addEventListener("click", function(event) {
			if(this.className == "h5p-question-check-answer h5p-joubelui-button"){
				if(parent.check_count < 2){
				  parent.check_count++;
				  H5P.jQuery('.h5p-interactive-video .h5p-question .h5p-joubelui-button.h5p-question-show-solution').hide();
				}else{
				  H5P.jQuery('.h5p-question-check-answer').hide();
				  H5P.jQuery('.h5p-question-try-again').hide();
				  H5P.jQuery('.h5p-interactive-video .h5p-question .h5p-joubelui-button.h5p-question-show-solution').show();

				}
			}
		});
	}
});