Greasy Fork

来自缓存

Greasy Fork is available in English.

Yinyuetai

免积分,免登录,既可观看、下载高清MV,支持1080p

当前为 2016-04-16 提交的版本,查看 最新版本

// ==UserScript==
// @name           Yinyuetai
// @author         hyk
// @namespace      [email protected]
// @description    免积分,免登录,既可观看、下载高清MV,支持1080p
// @version        1.1.2
// @create         2016-03-28
// @lastmodified   2016-03-31

// @include        http://v.yinyuetai.com/video/*
// @include        http://v.yinyuetai.com/playlist/*
// @copyright      2016+, hyk
// @require       http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js
// @grant          unsafeWindow
// @grant		GM_setClipboard
// @grant		GM_xmlhttpRequest
// @icon		http://www.yinyuetai.com/favicon.ico
// ==/UserScript==
(function () {
    var dhost = location.hostname,
        Lc = location,
        lurl = Lc.href;

    var win = (typeof unsafeWindow == 'undefined') ? window : unsafeWindow;
    var _Q = function (d) {
            return document.querySelector(d)
        },
        _Qa = function (d) {
            return document.querySelectorAll(d)
        };
    var DM = function (m) {

        return lurl.toLowerCase().indexOf(m) > 0;
    };

    function Log(l) { //调试用
        console.log(l);
    }

    //定义各大浏览器识别
    //    var OP = function () {
    //            return window.opera
    //        },
    //        GC = function () {
    //            return window.chrome
    //        },
    //        FF = function () {
    //            return window.sidebar
    //        };
    //    var $OP = function () {
    //        if (OP()) return $ = jQuery;
    //    }; //O下$修复





    function YYT() { //音悦台,免登录、积分、客户端,支持1080p
        //                function Yyt(Vid,index) {//此处修改自Music liker for beauty ByYulei
        //                  
        //                    GM_xmlhttpRequest({
        //                        url: 'http://www.yinyuetai.com/api/info/get-video-urls?videoId=' + Vid,
        //                        method: "get",
        //                        onload: function (y) {
        //                            var r = $.parseJSON(y.responseText);
        //                            if(DM('/playlist/')){
        //                                var oSpan=$("span.mv-quality-icon").eq(index);
        //                                r.hcVideoUrl ? oSpan.find("a.hc").attr('href', r.hcVideoUrl).show() : oSpan.find("a.hc").hide();
        //                                r.hdVideoUrl ? oSpan.find("a.hd").attr('href', r.hdVideoUrl).show() : oSpan.find("a.hd").hide();
        //                                r.heVideoUrl ? oSpan.find("a.he").attr('href', r.heVideoUrl).show() : oSpan.find("a.he").hide();
        //                               
        //                            }else{
        //                                
        //                                r.hcVideoUrl ? $('#p1').attr('href', r.hcVideoUrl).show() : $('#p1').hide();
        //                                r.hdVideoUrl ? $('#p2').attr('href', r.hdVideoUrl).show() : $('#p2').hide();
        //                                r.heVideoUrl ? $('#p3').attr('href', r.heVideoUrl).show() : $('#p3').hide();
        //                            }
        //                           
        //                           
        //                        }
        //                    })
        //                  
        //                }


        function _Yyt(Vid, index) {

            GM_xmlhttpRequest({
                url: 'http://ext.yinyuetai.com/main/get-h-mv-info?json=true&videoId=' + Vid,
                method: "get",
                onload: function (y) {
                    var r = $.parseJSON(y.responseText);
                    var aVideoUrlModels = r.videoInfo.coreVideoInfo.videoUrlModels;

                    //Log(r.videoInfo.coreVideoInfo.videoUrlModels);

                    var aVideoQuality = ["hc", "hd", "he", "sh"];
                    if (DM('/playlist/')) {
                        var oSpan = $("span.mv-quality-icon").eq(index);

                        for (var i = 0; i < aVideoUrlModels.length; i++) {
                            oSpan.find("a." + aVideoQuality[i]).attr('href', aVideoUrlModels[i].videoUrl).show();
                        }
                    } else {
                        for (var i = 0; i < aVideoUrlModels.length; i++) {
                            $("#video-quality-" + aVideoQuality[i]).attr('href', aVideoUrlModels[i].videoUrl).show();
                        }

                    }


                }
            })

        }
        if (DM('/playlist/')) {
            var MVlist = _Qa(".mvbox_list .mv_picBox");
            //Log(MVlist);
            $(".mvInfo_row01_left").after("<span id='ydList'>悦单列表地址</span><div class='box-container'><div class='wrapper-fixed'><ul class='MV_List'></ul></div></div><style>span#ydList{cursor:pointer;padding:3px;font-size:16px;position:relative;left:20px;top:10px;color:white;background-color:#333}span#ydList:hover{background-color:#404040;color:#27d5bf} div.box-container{display:none;background-color:#333;scrollbar-base-color:#333;width:320px;height:auto;position:absolute;z-index:200;float:left;} div.box-container div.wrapper-fixed{position:relative;}ul.MV_List {width:100%;max-height:505px;padding:0;overflow-y:scroll;}ul.MV_List li{position:relative;display:block;width:100%;list-style:none;float:left;height:40px;padding:5px 0;margin:0;border-bottom:1px solid #404040;text-align:left;}ul.MV_List li:hover{} div.video-wrapper{position:absolute;display:block;width:auto;height:auto;left:-300px;z-index:200}ul.MV_List li span.mv-quality-icon{margin-left:22px;display:inline-block;}span.mv-quality-icon .mv-url{display:none;padding-left:10px;padding-right:10px;margin-left:3px;}ul.MV_List li a{font-size:12px;color:white;text-align:left;margin-left:5px;}ul.MV_List span.mv-index{float:left;width:18px;height:18px;background-color:#f52f2f;text-align:center;vertical-align:middle;color:white;border-radius:50%;display:inline-block}a.sh{background-color:#31d457;}a.he{background-color:#1e65c6;}a.hd{background-color:#27d5bf;}a.hc{background-color:#e57834;}a.sh:hover{background-color:#3cf066}a.he:hover{background-color:#2b7ded}a.hd:hover{background-color:#35fce2}a.hc:hover{background-color:#f88843}p.mv-title{margin-left:25px;height:20px; color:white;font-size:12px;overflow:hidden}</style>");

            $("#ydList").click(function (e) {
             
          
                $(".mvInfo_row01").css({overflow:"visible",position:"relative"});
                $(".mvInfo_row02").css({display:"block",float:"left"});
                if ($("ul.MV_List li").length == 0) {
                    
                 
                    for (var i = 0; i < MVlist.length; i++) {
                        $("ul.MV_List").append("<li><span class='mv-index'>" + (i + 1) + "</span><p  class='mv-title' title='" + MVlist[i].getAttribute('data-title') + "'>" + MVlist[i].getAttribute('data-title') + "</p><span class='mv-quality-icon'><a target='_blank' class='mv-url sh'>sh</a><a target='_blank' class='mv-url he'>he</a><a target='_blank' class='mv-url hd'>hd</a><a target='_blank' class='mv-url hc'>hc</a></span></li>");
                        _Yyt(MVlist[i].getAttribute('data-id'), i);                
                    }
                   
                    var timeIDC,timeIDD;
                    var offsetX=$(".mvInfo_row01_left").outerWidth(true)+20+"px";
                    var offsetY="-"+($("div.box-container").outerHeight(true))+"px";
                       $("div.box-container").css({
                        "left": offsetX,
                        "top": offsetY
                    });
                    
                    var flag="";
                    var timeID,timeOffID;
                    var enterVideoWrapper=false;
                    var listItemEnter=function(e){
						 
						if(e.target.tagName=="P"||e.target.tagName=="SPAN")
                {
                  //console.log(e.target.parentNode);
                  e.target=e.target.parentNode;
                  
                }
						if(e.target.tagName=="A")
							e.target=e.target.parentNode.parentNode;
						/*if(e.data.message)
                   			 alert(e.data.message);
						else
							alert("off");*/
                    clearTimeout(timeID);
                    enterVideoWrapper=false;
                    var _self=$(this);
                    if(flag==$(e.target).find(".mv-index").text()){
                      return;
                      }
                    else{
                         if(flag!=""){
                       try{
                            clearTimeout(timeID);
                            $("ul.MV_List li").eq(parseInt(flag)-1).css("background-color","#333");
                              _self.parent().parent().find("div.video-wrapper").remove();
                            }catch(e){}
                           }
                    }
                    flag=$(e.target).find(".mv-index").text();
                
                       var videoWrapper_offsetY=Math.round(((_self.find("span.mv-index").text()-1)*_self.innerHeight()-$("ul.MV_List")[0].scrollTop))+"px";
                      timeID=setTimeout(function(){
                         $(e.target).css("background-color","#111");
                         var videoDiv=_self.parent().parent().append("<div class='video-wrapper'><video src='' autoplay='autoplay' controls='controls' width='300px' height='200px'></video></div>");
                          videoDiv.find("video").attr("src",_self.find("a.hc").attr("href"));
                          videoDiv.find("div.video-wrapper").css("top",videoWrapper_offsetY);
                          videoDiv.find("div.video-wrapper").mouseenter(function(){
                            $("ul.MV_List li").eq(parseInt(flag)-1).css("background-color","#111");
                          });
                      },500);
                  };
                    
                    
                  $("div.box-container").on("mouseenter","ul.MV_List li",{message:"on"},listItemEnter);
          
                  $("ul.MV_List").scroll(function(){
                      clearTimeout(timeOffID);
					 
                       $("div.box-container").off("mouseenter","ul.MV_List li",listItemEnter);
                      timeOffID=setTimeout(function(){
                           $("div.box-container").on("mouseenter","ul.MV_List li",{message:"on"},listItemEnter);
                      },200);
                  });
                  $("div.box-container").mouseleave(function(){
                     try{
                            clearTimeout(timeID);
                              $(this).parent().parent().find("div.video-wrapper").remove();
                            }catch(e){}
                  });
               
                }
                if ($("div.box-container").is(":visible")) {
                    $("div.box-container").hide();
                } else {
                    $("div.box-container").show();
                }

            });

            //Log($("ul.MV_List a.mv_URL"));
        } else {
            var tbk = 'target="_blank"';
            $('div.pl_title.fl').after('<span  id="Ytai" ' + '><span style="background-color:#484848;height:38px;border-radius:5px;padding:5px;padding-bottom:6px;" class="ico download_ico ico20_pl_down"><a id="video-quality-hc" ' + tbk + ' >标清</a><a id="video-quality-hd" ' + tbk + '>高清</a><a id="video-quality-he" ' + tbk + '>超清</a><a id="video-quality-sh" ' + tbk + '>会员</a></span></span><style>#Ytai a{display:none;margin:3px;color:white;}#Ytai a:hover{color:#669900;}#Ytai{position:relative;left:10px;}</style>');

            _Yyt($('.videoinfobox').attr('videoid') || $('.play a').eq(0).attr('href').match(/\d+/)[0]);
        }

    }

    //
    //    if (!window.sidebar) {
    //        window.addEventListener('DOMContentLoaded', Yu, false);
    //    } else {
    //        YYT();
    //    };
    // 
    YYT();

})();