度盘给我播!

强迫度盘打开 ts mts f4v m2ts等视频文件的播放页面。

As of 2017-09-09. See the latest version.

// ==UserScript==
// @name         度盘给我播!
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  强迫度盘打开 ts mts f4v m2ts等视频文件的播放页面。
// @author       coolwind2012
// @match        http*://pan.baidu.com/disk/home*
// @exclude      http*://pan.baidu.com/disk/home*search*
// @icon         https://pan.baidu.com/box-static/disk-system/images/favicon.ico
// @require      https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js
// @grant        none
// ==/UserScript==

change = function(){
    'use strict';
    var mediaType = new Array('ts','3gp2','3g2','3gpp','amv','divx','dpg','f4v','m2t','m2ts','m2v','mpe','mpeg','mts','vob','webm','wxp','wxv');
    var myPath = '';
    // @match        http*://pan.baidu.com/s/*/path=*
    if(location.href.indexOf('.com\/s\/1')>1)
    {
        // 需要shareid
        var uk      = yunData.SHARE_;
        var shareId = yunData.SHARE_ID;
        //  t = b.getElementDataByPosition(e); //e=_position
        //  var fid = t.fs_id;
        //myPath = 
    }
    // https://pan.baidu.com/disk/home#list/path=%2F&vmode=list
    if(location.href.indexOf('/disk/home')!==-1)
    {
        myPath = location.href.split('path=')[1].split('&')[0];
    }
    myPath += (myPath.slice(-3)==='%2F')?'':'%2F';
    //var myPath = location.href.split('path=')[1];
    // 从搜索页面得到的
    // https://pan.baidu.com/disk/home#search/key=.ts&vmode=list
    // 暂时还是无能为力啊 T_T
    $(".vdAfKMb").children("dd:not(.open-enable)").each(function(){
        var houzhui = $(this).find('.text a').attr('title').split('.').pop();
        //alert(houzhui);
        if(isMedia(houzhui))
        {
            var tmp = $(this).find('.text a').attr('href');
            //  !_-+=~@#$%^&()
            //  !_-%2B%3D~%40%23%24%25%5E%26()
            if(tmp === 'javascript:void(0);'){
                var tmpTitle = $(this).find('.text a').attr('title');
                $(this).find('.text a').attr('href'  ,  'https://pan.baidu.com/play/video#video/path=' +  myPath  + encodeURIComponent(tmpTitle) +  '\&t=-1').attr('target','_blank_');
                $(this).find('.avjZ2gA').removeClass('default-small').addClass('fileicon-small-video');// default-small
            }
            $(this).addClass("open-enable");
        }
    });

    function isMedia(str){
        var tmp = str.toLowerCase();
        for(var i=0;i<mediaType.length;i++)
        {
            if(tmp===mediaType[i])
                return 1;
        }
        return 0;
    }
};

$('.vdAfKMb').ready(    function() {
    change();
});
var myhash = location.href;
var timeid = window.setInterval(function(){
if(location.href!==myhash){change();myhash=location.href;}
},200);