虎牙免登录高清看视频脚本

// ==UserScript==
// @name         虎牙免登陆
// @version      0.1
// @description  自动刷新机制
// @author       You
// @match        *www.huya.com/*
// @grant        none
// @require      https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// @namespace
// ==/UserScript==

(function() {
    'use strict';
    console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    var begin=new Date();

    wait4Element("#player-login-tip-wrap", 1000, begin,function() {
       console.log("要求登陆")
        $("#player-login-tip-wrap").hide()
        window.location.reload();
    });
})();

function wait4Element(selector, time,begin, func) {
     var span = new Date().getTime() - begin.getTime();
    console.log("从开始计时:"+(span/1000).toFixed(1)+"秒 "+(span/1000/60).toFixed(1)+"分")
    if (document.querySelector(selector) !== null) {
        console.log("要求登录...")
        window.localStorage.setItem("虎牙不登录时间",(span/1000/60).toFixed(1)+"分")
        func();
    } else {
        setTimeout(function() {
            wait4Element(selector, time, begin,func);
        }, time);
    }
}

评论

暂无评论