Answer the question
In order to leave comments, you need to log in
How to intercept subtitles for youtube video from js?
Actually the task is completely the following: I need to display the titles for the video outside the video.
To do this, you need to somehow intercept the subtitle change event and get the current ones.
How to do it?
Answer the question
In order to leave comments, you need to log in
In general, for good, all subtitles can be obtained at this link
This can be done for any video that has subtitles. v
You need to substitute the video identifier from the URL in the parameter , for example, for https://www.youtube.com/watch?v=7Y7LGxinPH0 , you need to substitute in the link to get subtitles 7Y7LGxinPH0
, and then process the subtitles in time relative to the received XML.
But you can just listen to them. Connect jQuery to the video page:
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
jQuery('body').on('DOMNodeInserted', 'span.captions-text span', function () {
console.log(jQuery(this).text());
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question