I'd like to use Greasemonkey to add a subtitle download button for Openload VTT subtitles. However, I can't figure out how to access the <track> tag.
Take, for example, this French video clip with English subtitles. When I looked at the source code in Firefox, I found this:
<video id="olvideo" width="100%" height="100%" crossorigin="anonymous" controls>
<track kind="captions" src="https://thumb.oloadcdn.net/subtitle/rjC09fkPLYs/vt8zTaIaVqQ.vtt" srclang="en" label="English" default />
</video>
Why doesn't my proof-of-concept Greasemonkey code work?
// ==UserScript==
// @name Openload
// @include *openload.co*
// @run-at document-idle
// ==/UserScript==
var video = document.querySelector("video");
if (video) {
var track = video.querySelector("track");
if (track) {
alert ("<track> FOUND.");
} else {
alert ("<track> NOT found!");
}
} else {
alert ("<video> tag not found");
}
(When I ran the script I got the message "<track> NOT found!".)