Greasy Fork

来自缓存

Greasy Fork is available in English.

Yinyuetai

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

当前为 2016-06-03 提交的版本,查看 最新版本

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

// @include        http://v.yinyuetai.com/video/*
// @include        http://v.yinyuetai.com/playlist/*
// @copyright      2016+, hyk
// @require       http://code.jquery.com/jquery-2.2.4.min.js
// @grant          unsafeWindow
// @grant		GM_addStyle
// @grant		GM_xmlhttpRequest
// @icon		http://www.yinyuetai.com/favicon.ico
// @updatelog [2016-06-03] 将鼠标悬浮视频预览改为鼠标点击显示,并可快速聚焦到正在播放的项

// ==/UserScript==

//======= 禁止商业用途 ===========//
//======= 禁止商业用途 ===========//
//======= 禁止商业用途 ===========//


//======== start =================//

    var XHR=function(type,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 (type=='pl') {
                        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(); 
                    }
                }
            });
    };
    function mvPage(appendTo){
        style('mv');
        var DOMSnippet="<span  id='Ytai' >\
                                        <a id='video-quality-hc' target='_blank'>标清</a>\
                                        <a id='video-quality-hd' target='_blank'>高清</a>\
                                        <a id='video-quality-he' target='_blank'>超清</a>\
                                        <a id='video-quality-sh' target='_blank'>会员</a>\
                                     </span>";
        
        $(appendTo).after(DOMSnippet);

        XHR('mv',$(appendTo).parent().parent().attr('videoid'));
        
    }
    
    function plPage(appendTo){
        style('pl');
         var MVlist = $(".mvbox_list .mv_picBox");
            //Log(MVlist);
         var DOMSnippet="<span id='ydList'>悦单列表地址</span>\
                         <div class='box-container'>\
                            <div class='wrapper-fixed'>\
                                <ul class='MV_List'></ul>\
                            </div>\
                        </div>";
        var offsetX=$(appendTo).outerWidth(true)+20;
        var offsetY=0;
            $(appendTo).after(DOMSnippet);

            $("#ydList").click(function (e) {
                if ($("div.box-container").is(":visible")) {
                    $("div.box-container").hide();
                    if($('div.box-container .wrapper-fixed .video-wrapper'))
                        $('div.box-container .wrapper-fixed .video-wrapper').remove();
                    $('div.box-container ul.MV_List li').css('background-color','transparent');
                } else {
                    $("div.box-container").show();
                }
                
                $(".mvInfo_row01").css({overflow:"visible",position:"relative"});
                $(".mvInfo_row02").css({display:"block",float:"left"});
                if ($("ul.MV_List li").length != MVlist.length) {
                    
                 
                    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>");
                        XHR('pl',MVlist[i].getAttribute('data-id'), i);                
                    }
                    
                     offsetY="-"+($("div.box-container").outerHeight(true))+"px";
					
                    $("div.box-container").css({
                                                    "left": offsetX,
                                                    "top": offsetY
                                                });
                }
            });
                   
                   
                    
                    
                    
                  $("div.box-container").on("click","ul.MV_List li .mv-quality-icon a",function(e){
                         e.preventDefault();
                      
                        if($(e.target).hasClass('active')){
                            $(e.target).removeClass('active');
                            $(e.target).parent().parent().css('background-color','transparent');
                            $(e.target).parent().parent().parent().parent().find('.video-wrapper').remove();
                            return;
                        }else{
                            $(e.target).parent().parent().parent().find('li').css('background-color','transparent');
                            $(e.target).parent().parent().parent().find('a.mv-url').removeClass('active');
                            if( $(e.target).parent().parent().parent().parent().find('.video-wrapper'))
                                 $(e.target).parent().parent().parent().parent().find('.video-wrapper').remove();
                            $(e.target).addClass('active');
                            $(e.target).parent().parent().css('background-color','#111');
                        }
                        
                         var videoWrapper_offsetY=Math.round(($(e.target).parent().parent().find("span.mv-index").text()-1)*$(e.target).parent().parent().innerHeight()-$("ul.MV_List")[0].scrollTop)+"px";
                     
                         var videoDiv=$(e.target).parent().parent().parent().parent().append("<div class='video-wrapper'>\
                                                                                                        <div class='preMV-caption'>\
                                                                                                            <span class='caption-title'></span>\
                                                                                                            <span class='btn-close'>X</span>\
                                                                                                        </div>\
                                                                                                        <video src='' autoplay='autoplay' controls='controls' width='300px' height='200px'></video>\
                                                                                                </div>");
                            
                          videoDiv.find("video").attr("src",$(e.target).attr("href"));
                      
                          var title=$(e.target).parent().siblings(".mv-title").text();
                          var mv_index= $(e.target).parent().siblings(".mv-index").text();
                          videoDiv.find(".preMV-caption .caption-title").attr('mv-index',mv_index).attr('title',title).text(title).click(function(e){
                             
                              $('ul.MV_List').animate({
                                  scrollTop:($(e.target).attr('mv-index')-1)*$('ul.MV_List li').innerHeight()-parseInt($(e.target).parent().parent().css('top'))+"px"
                              },500);
                          });
                          videoDiv.find(".preMV-caption .btn-close").click(function(e){
                              $('.wrapper-fixed').find('.video-wrapper').remove();
                          });
                          videoDiv.find("div.video-wrapper").css({top:videoWrapper_offsetY,left:offsetX<320?$("div.box-container").outerWidth():"-"+$("div.box-container").outerWidth()+"px"});
                         
                  });
          
                
             
               
              
              

           
} 

function style(p){
    var css='';
    switch(p){
        case 'mv':
            css="#Ytai{\
                            background-color: rgba(255, 255, 255, 0.1);\
                            border-radius: 4px;\
                            padding: 5px 8px;\
                        }\
                 #Ytai a{\
                            display:none;\
                            margin:3px;\
                            color:white;\
                        }\
                 #Ytai a:hover{\
                            color:#669900;\
                        }\
                 #Ytai{\
                            position:relative;\
                            left:10px;\
                        }";
            break;
        case 'pl':
            css="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;\
                                float:left;\
                                z-index:1000000;\
                            }\
                div.box-container div.wrapper-fixed{\
                                position:relative;\
                            }\
                div.box-container div.wrapper-fixed ul.MV_List {\
                                width:100%;\
                                max-height:505px;\
                                padding:0;\
                                overflow-y:scroll;\
                           }\
                div.box-container div.wrapper-fixed 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;\
                            }\
                div.box-container div.wrapper-fixed ul.MV_List li:hover{\
                                background-color:#111 !important;\
                            }\
                div.box-container div.wrapper-fixed div.video-wrapper{\
                                position:absolute;\
                                display:block;\
                                width:300px;\
                                height:auto;\
                                left:-300px;\
                            }\
                div.box-container div.wrapper-fixed div.video-wrapper video{\
                                float:left;\
                                width:100%;\
                            }\
                div.box-container div.wrapper-fixed div.video-wrapper .preMV-caption{\
                                float:left;\
                                width:100%;\
                                background-color:rgba(0,0,0,0.3);\
                            }\
                div.box-container div.wrapper-fixed div.video-wrapper .preMV-caption .caption-title{\
                                display:inline-block;\
                                max-width:260px;\
                                height:22px;\
                                overflow:hidden;\
                                color:white;\
                                font-size:14px;\
                                cursor:pointer;\
                            }\
                div.box-container div.wrapper-fixed div.video-wrapper .preMV-caption .btn-close{\
                                float:right;\
                                padding:0px 6px;\
                                color:white;\
                                border:1px solid white;\
                                cursor:pointer;\
                            }\
                div.box-container div.wrapper-fixed ul.MV_List li span.mv-quality-icon{\
                                margin-left:22px;\
                                display:inline-block;\
                            }\
                div.box-container div.wrapper-fixed ul.MV_List li span.mv-quality-icon .mv-url{\
                                display:none;\
                                padding-left:10px;\
                                padding-right:10px;\
                                margin-left:3px;\
                                color:white;\
                            }"+   
                "div.box-container div.wrapper-fixed ul.MV_List li 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\
                            }\
                div.box-container div.wrapper-fixed ul.MV_List li span.mv-quality-icon a.sh{\
                                background-color:#31d457;\
                    }\
                div.box-container div.wrapper-fixed ul.MV_List li span.mv-quality-icon a.he{\
                                background-color:#1e65c6;\
                    }\
                div.box-container div.wrapper-fixed ul.MV_List li span.mv-quality-icon a.hd{\
                                background-color:#27d5bf;\
                    }\
                div.box-container div.wrapper-fixed ul.MV_List li span.mv-quality-icon a.hc{\
                                background-color:#e57834;\
                    }\
                div.box-container div.wrapper-fixed ul.MV_List li span.mv-quality-icon a.sh:hover{\
                                background-color:#3cf066\
                    }\
                div.box-container div.wrapper-fixed ul.MV_List li span.mv-quality-icon a.he:hover{\
                                background-color:#2b7ded\
                    }\
                div.box-container div.wrapper-fixed ul.MV_List li span.mv-quality-icon a.hd:hover{\
                                background-color:#35fce2\
                    }\
                div.box-container div.wrapper-fixed ul.MV_List li span.mv-quality-icon a.hc:hover{\
                                background-color:#f88843\
                    }\
                div.box-container div.wrapper-fixed ul.MV_List li p.mv-title{\
                                margin-left:25px;\
                                height:20px;\
                                color:white;\
                                font-size:12px;\
                                overflow:hidden\
                    }";
            
            break;
        default:
            break;
    }
    GM_addStyle(css);
}

    
(function YYT(type){
    
    if(type=='pl'){    
        plPage('.mvInfo_row01_left');
    }else{
        mvPage('div.pl_title.fl');
    }
})(unsafeWindow.location.href.indexOf('/playlist/')>0?'pl':'mv') 



//==============================================================================//
//                                                                              //
//                                                                              //
//          ==      ==         ===        ===          ===    ===               //
//          ==      ==           ==      ==             ==    ==                //
//          == ==== ==            == == ==              ==   ==                 //
//          == ==== ==               ==                 == ===                  //
//          ==      ==               ==                 ==   ===                //
//          ==      ==               ==                 ==     ====             //
//                                                                              //
//==============================================================================//