我想在youtube主页上执行以下代码:
for(var i =0; i<document.getElementsByClassName("yt-simple-endpoint style-scope ytd-grid-video-renderer").length + 1000; i++){
if(document.getElementsByClassName("yt-simple-endpoint style-scope ytd-grid-video-renderer")[i].innerHTML.indexOf("a") != -1){
document.getElementsByClassName("yt-simple-endpoint style-scope ytd-grid-video-renderer")[i].innerHTML = 'oui';
}
}
问题在于,这仅适用于开始加载页面的第一部分,不适用于我向下滚动的页面,因为youtube会在页面上加载新内容。那么,每次出现这些新元素时,如何重新执行代码?