虎牙免登陆

虎牙免登陆换画质

// ==UserScript==
// @name         虎牙免登陆
// @version      0.11
// @description  虎牙免登陆换画质
// @author       You
// @match        http://www.huya.com/*
// @grant        none
// @require      http://code.jquery.com/jquery-1.7.2.min.js
// @namespace https://greasyfork.org/users/165658
// ==/UserScript==

(function() {
    'use strict';
    wait4Element("li[ibitrate='2000']", 1000, function() {
      console.log('no login loaded');
      $('#player-login-tip-wrap').remove();
      $(".player-videotype-list li").click(function(e) {
        var n = this;
        console.log(this);
        var s = $(n).attr("iBitRate");
        var o = $(n).attr("channelId");
        vplayer.vcore.reqBitRate(s,o);
        $('ul.player-videotype-list > li.on').removeClass('on');
        $(this).addClass('on');
        $('span.player-videotype-cur').text($(this).text());
        $('#player-login-tip-wrap').remove();
        $('.player-chest-login').remove();
      });
   });
})();

function wait4Element(selector, time, func) {
    if (document.querySelector(selector) !== null) {
        func();
        return;
    } else {
        setTimeout(function() {
            wait4Element(selector, time, func);
        }, time);
    }
}