본문 바로가기

script collection 1

by peach1227 2023. 8. 19.
<script>
const timestamps=document.querySelectorAll('.segment-timestamp');
const texts=document.querySelectorAll('.segment-text');

const div=document.createElement('div');
div.id="transcript";
div.className="transcript";
div.style="width:100%;height:auto;position:relative;"
document.body.insertBefore(div,document.body.firstElementChild);
for (let i=0;i<timestamps.length;i++){

if(timestamps.length-1 !== i){
div.innerHTML +='<span  class="start">'+timestamps[i].textContent+'</span>'+
'<span  class="end">'+timestamps[i+1].textContent+'</span>'+'<span class="text">'+
texts[i].textContent+'</span>'+"<br>";
}else{console.log("last Line!");
div.innerHTML +='<span  class="start">'+timestamps[i].textContent+'</span>'+
'<span  class="end">'+timestamps[i].textContent+'</span>'+'<span class="text">'+
texts[i].textContent+'</span>'+"<br>";
}

}
</script>
<script>

for (let i=0 ; i< texts.length;i++){
console.log(texts[i]);
texts[i].addEventListener('click',(e) => {
//alert("yes");
start.value=e.target.previousElementSibling.previousElementSibling.textContent;
end.value=e.target.previousElementSibling.textContent;
button_update.click();
},false);
}

</script>
반응형