サンプルソースを書いたのでブログへ掲載。
// ボタンクリック
btnClick = function(){
// 繰り返し処理
setInterval(function(){
// iframeに設定されているIDを種族
const elem = document.getElementById('iframe');
// Iframe内で取得したい要素を取得
const status = elem.contentWindow.document.querySelector('span').outerHTML;
// 条件分岐
if(status.indexOf('hogehoge') > 0) {
// やりたいこと①
elem.contentWindow.document.getElementById('hogehoge1').click();
} else {
// やりたいこと②
elem.contentWindow.document.getElementById('hogehoge2').click();
}
},5000); // 5秒毎
}