美文网首页
获取字幕

获取字幕

作者: lindyang | 来源:发表于2020-09-02 15:43 被阅读0次
    function formatTS(delta) {
        var date = new Date(new Date().getTime() - window.start + (delta || 0));
        return "00:" +
            ("0" + date.getMinutes()).slice(-2) + ":" +
            ("0" + date.getSeconds()).slice(-2) + "," +
            ("00" + date.getMilliseconds()).slice(-3);
    }
    
    function printTexts() {
        console.log(
            window.texts.join("")
            // + formatTS() + "\r\n" + window.sub + "\r\n\r\n"
        );
        return "";
    }
    
    function record() {
        document.getElementsByTagName("video")[0].click();
        window.start = new Date().getTime() - 1;  // global
        window.texts = new Array();
        window.texts.push(
            "1" + "\r\n"
            // + formatTS() + " --> "
        );
        window.i = 2;                             // global
        window.sub = "";                          // global
        window.lastSub = "";
        setInterval(function() {
            // DOMSubtreeModified
            window.sub = document.getElementsByClassName("css-jrziy5")[0].innerText;
            if (window.lastSub !== window.sub) {
                console.log(window.sub);
                window.texts.push(
                    // formatTS(-5) + "\r\n" +
                    window.sub + "\r\n" +
                    "\r\n" +
                    (window.i++) + "\r\n"
                    // + formatTS() + " --> "
                );
                window.lastSub = window.sub;
            }
        }, 10);
        return "start recording...";
    }
    
    record();
    

    相关文章

      网友评论

          本文标题:获取字幕

          本文链接:https://www.haomeiwen.com/subject/rhdwsktx.html