自动打开b站的字幕

自动打开b站的字幕,每条视频都会

// ==UserScript==
// @name         自动打开b站的字幕
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  自动打开b站的字幕,每条视频都会
// @author       小伍
// @license      MIT
// @match        https://www.bilibili.com/video/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
// @grant        none
// ==/UserScript==

(function() {
    window.onload = function() {
        let hrefId = window.location.href.split('&')[0].split('=')[1];
        var s = null;
        s = setInterval(function (){
            let len = document.getElementsByClassName('bpx-common-svg-icon').length;
            if(len === 23){
                document.getElementsByClassName('bpx-common-svg-icon')[5].click();
                clearInterval(s);
            }
        },100);
        var s1 = setInterval(function (){
            let thisId = window.location.href.split('&')[0].split('=')[1];
            if(thisId !== hrefId){
                if (s) {
                    clearTimeout(s);
                }
                s = setInterval(function (){
                    let len = document.getElementsByClassName('bpx-common-svg-icon').length;
                    if(len === 23){
                        document.getElementsByClassName('bpx-common-svg-icon')[5].click();
                        clearInterval(s);
                    }
                },100);
                hrefId = thisId;
            }
        },100);
    };
})();