Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
// ==UserScript==
// @name         動漫瘋 m3u8 連結取得
// @namespace    none
// @version      1.00
// @description  取得動漫瘋m3u8檔案,用potplayer觀看,已經接近正式版
// @author       sheepdragon
// @match        *://ani.gamer.com.tw/animeVideo.php?sn=*
// @grant        none
// @icon         https://i2.bahamut.com.tw/anime/baha_s.png
// ==/UserScript==
//https://greasyfork.org/scripts/26825
(function() {
    'use strict';
    // Your code here...
    var snID = animefun.videoSn;
    var deviceID = animefun.getdeviceid() , listSrc, Origin, Words = [],
        //secs倒數秒數 rsec下次時間
        Player = [],Info, ad= getAd()[0], sec= 6,secs= 0,rsec=6, max = 10 , now = 0,
        adID, resolution = ['360p', '540p', '720p', '1080p'],
        locked = true,hash,
        txtA = '如果需要線上播放建議重新整理,無的話請使用使m3u8',txtB = '這次播放不會有廣告 (◔౪◔)~',txtC = '已經取得 _(:3 」∠ )_';
    $(document).ajaxSuccess(
        function(event, xhr, settings) {
            //settings.url.search("token.php?")>1
            if (settings.url.match(/ajax\/token\.php\?adID\=\d+&sn\=\d+&device\=[0-9a-z]+&hash\=[0-9a-z]+/) !== null) {
                Info=$.parseJSON(xhr.responseText);
                //console.log(Info);
                let url = settings.url.split('?')[1];
                let get = url.split('&');
                for (let i in get) {
                    let nam = get[i].split('=')[0];
                    let val = get[i].split('=')[1];
                    let has = get[i].split('=')[1];
                    if (nam === 'adID') {
                        adID = val;
                    } else if (nam === 'device') {
                        // deviceID = val;
                    }
                    else if(has === 'hash'){
                        hash=has;
                    }
                }
                control();
            }
        });
    function remove(){
        $('.ncc a').eq(0).click(function() {
            setTimeout(function() {
                $('.vast-blocker').removeAttr('href');
                $('.vast-blocker').removeAttr('target');
                $('.vast-skip-button').attr("href", "#");
                $('.vast-skip-button').removeAttr("target");
                $('#ani_video').removeClass('vjs-ad-playing');
            }, 500);
        });
    }
    let getM3u8s = () => {
        return new Promise(function(resolve, reject) {
            $.ajax({
                url: 'ajax/m3u8.php',
                data: { sn: snID, device: deviceID},
                type: "GET",
                dataType: 'json',
                success: resolve,
                error: reject
            });
        });
    };
    let CastVishu = () => {
        return new Promise(function(resolve, reject) {
            $.ajax({
                url: 'ajax/videoCastcishu.php',
                data: { sn: snID, s: adID },
                type: "GET",
                dataType: 'text',
                success: resolve,
                error: reject
            });
        });
    };
    let CastVishuAD = () => {
        return new Promise(function(resolve, reject) {
            $.ajax({
                url: 'ajax/videoCastcishu.php',
                data: { sn: snID, s: ad },
                type: "GET",
                dataType: 'text',
                success: resolve,
                error: reject
            });
        });
    };
    let token = () => {
        return new Promise(function(resolve, reject) {
            $.ajax({
                url: 'ajax/token.php',
                data: { sn: snID, device: deviceID ,'hash':hash,'adID':adID },
                type: "GET",
                dataType: 'text',
                success: resolve,
                error: reject
            });
        });
    };
    let checklock = () => {
        return new Promise(function(resolve, reject) {
            $.ajax({
                url: 'ajax/checklock.php',
                data: { device: deviceID, sn: snID },
                type: "GET",
                dataType: 'text',
                success: resolve,
                error: reject
            });
        });
    };
    let CastVishuEnd = () => {
        return new Promise(function(resolve, reject) {
            $.ajax({
                url: 'ajax/videoCastcishu.php',
                data: { sn: snID, s: ad, ad: 'end' },
                type: "GET",
                dataType: 'html',
                success: resolve,
                error: reject
            });
        });
    };
    let getM3u8Lists = () => {
        return new Promise(function(resolve, reject) {
            $.ajax({
                url: listSrc,
                type: "GET",
                dataType: 'text',
                success: resolve,
                error: reject
            });
        });
    };
    function control() {
        if(Info.time===1){
        }
        else{
            reGET( true );
        }
    }
    function view(){
        if( now < max ){
            var viewsec=setInterval(function(){
                sec--;
                if(sec==7 && now!==0){
                    show( '重試進度' + now + '/'+ max +'(' + (now/max)*100 +')%');
                    secs=7;
                }
                else if(now===0){
                    show(sec+'秒後取得');
                }
                else{
                    show(sec+'秒後..重試');
                }
                if(sec<=0){
                    sec=rsec;
                    clearInterval(viewsec);
                    reGET(false);
                }
            }, 1000);
        }
        else{
            show('放棄~失敗');
        }
    }
    function reGET( lock = false){
        show('解鎖中...');
        setTimeout(function() {
            CastVishuEnd().then(function(msg) {
                show('成功CastVishuEnd');
            }).catch(function(xhr, ajaxOptions, thrownError) {
                show('取得重新CastVishuEnd失敗');
            });
            getM3u8s().then(function(msg) {
                //console.log(msg.src.length);
                if(msg.src.length>0){
                    show('取得getM3u8Lists');
                    listSrc = msg.src;
                    getM3u8Lists().then(function(msg) {
                        Origin=msg.split('\n');
                        if(Origin.length<20){
                            stringPlus();
                            show(txtA);
                        }
                    }).catch(function(xhr, ajaxOptions, thrownError) {
                        show('重新getM3u8Lists失敗');
                    });
                }
                else{
                    now ++;
                    show(now + '/'+ max +'(' + (now/max)*100 +')% 失敗');
                    view();
                }
            }).catch(function(xhr, ajaxOptions, thrownError) {
                show('取得重新getList失敗');
            });
        },secs*1000);
    }
    function show(msg = false) {
        $('#error_msg').remove();
        $('.bullet-send-tip').html(msg);
    }
    function stringPlus() {
        //console.log((Origin.length-3)/2+'種 解析度');
        for (let i in Origin) {
            if (Origin[i].length > 150) {
                Words.push(Origin[i]);
            }
        }
        Core();
    }
    function Core() {
        //$('.m3u_bn').remove();
        //$('.sub_top').html('<div class="ani-tabs__item"><a class="ani-tabs-link" onclick="$(\'#m3u8\').slideToggle(\'slow\')" >選擇畫質</a></div>' + $('.sub_top').html());
        $('.sub_top').append('<div class="ani-tabs__item"><a onclick="$(\'.ani-tabs-link\').removeClass(\'is-active\');$(this).addClass(\'is-active\');$(\'.ani-tab-content__item\').hide();$(\'#ani-tab-content-3\').show();" class="ani-tabs-link" id="m3u8Link">選擇畫質</a></div>');
        $('.ani-tab-content').append('<div id="ani-tab-content-3" class="ani-tab-content__item"></div>');
        $('#ani-tab-content-3').append("<div class='m3u_ul ani-setting-section'>M3U8 連結</div>");
        for (let i in Words) {
            let m3u_name = Words[i].split('-video')[0];
            let m3u_url = Words[i].split('-video=')[1];
            let Link = "http://gamer-cds.cdn.hinet.net/vod/gamer/" + m3u_name + "/hls-ae-2s/" + Words[i];
            Player.push(Link);
            let id = 'link_' + i;
            let span= "<span class='ani-setting-label__mian'>" + (!resolution[i] ? '' : resolution[i]) + "</span>";
            let label="<div class=''>" + span + "</div>";
            let item= "<div class='m3u_li ani-setting-item ani-flex ' title='點擊後複製' onclick=\"copy('" + Link + "');show('複製成功');\">" + label + "</div>";
            $('#ani-tab-content-3').append(item);
        }
        $('.ani-tabs-link').removeClass('is-active');
        $('#m3u8Link').addClass('is-active');
        $('.ani-tab-content__item').hide();
        $('#ani-tab-content-3').show();
    }
    function ShowHide() {
        $('#m3u8').slideToggle("slow", function() {
            // Animation complete.
        });
    }
    $(window).load(function() {
        /* FB移除器*/
        $('#fb_xdm_frame_https').eq(0).remove();
        $('iframe').eq(1).remove();
        $('.fb_ltr').remove();
        $('#facebook').remove();
        var block = setInterval(function() {
            //document.getElementById('ani_video_html5_api').currentTime+=30;
            if ($('.vast-skip-button').length === 1) {
                $('.vast-blocker').removeAttr('href');
                $('.vast-blocker').removeAttr('target');
                $('.vast-skip-button').attr("href", "#");
                $('.vast-skip-button').removeAttr("target");
                $('#ani_video').removeClass('vjs-ad-playing');
                if ($('.vast-skip-button')[0].text === '點此跳過廣告') {
                    //window.location.reload();
                    clearInterval(block);
                }
            }
        }, 500);
    });
    $(document).ready(function(){
        getM3u8s().then(function(msg) {
            if(msg.src.length>0){
                show('取得getM3u8Lists');
                listSrc = msg.src;
                getM3u8Lists().then(function(msg) {
                    Origin=msg.split('\n');
                    if(Origin.length<20){
                        stringPlus();
                        $('.bullet-send-tip').html(Math.round(Math.random())?txtB:txtC);
                        //show('取得成功');
                        token();
                    }
                }).catch(function(xhr, ajaxOptions, thrownError) {
                    show('取得getM3u8Lists失敗');
                });
            }
            else{
                show('載入中...');
                $('.bullet-send-tip').html('請先不要開始播放...哐哐');
                CastVishuAD().then(function(msg) {
                    console.log('呼叫AD成功');
                }).catch(function(xhr, ajaxOptions, thrownError) {
                    show('呼叫AD失敗');
                });
            }
        }).catch(function(xhr, ajaxOptions, thrownError) {
            show('取得getM3u8s失敗');
        });
    });
    $('head').append(`
<script>
function copy(str){\
$('body').append('<textarea id=\"temp\">'+ str +'</textarea>');\
$('#temp').select();\
document.execCommand('Copy');\
$('#temp').remove();\}
function show(msg = false) {
$('#error_msg').remove();
//$('.sub_top').append('<span id="error_msg">' + msg + '</span>');
}
</script>`);
    $('head').append(`<style>
.m3u_ul{
padding: 8px 16px;
font-size: 18px;
line-height: 1.4;
color: #028099;
padding-bottom: 0;
margin-bottom: 0;
}
.m3u_li{
display: inline-block !important;
width: 40%;
font-size: 1.5rem;
padding: 10px;
margin: 10px;
border-radius: 5px;
font-size: 2rem;
text-align: center;
line-height: 2.25em;
color:#333;
background-color: #0000000a;
transition: 10ms;
transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1.79);
cursor: pointer;
}
.m3u_li:hover{
background-color: #0000001f;
}
.m3u_li:active{
background-color: #00000036;
}
.m3u_li>div:after{
opacity: 0;
content: "已複製";
position: absolute;
display: block;
font-size: 0.7em;
margin-top: 3px;
margin-left: 42px;
background-color: #00b4d9;
line-height: 1em;
color: #FFF;
padding: 3px;
border-radius: 5px;
transition: 0.2s;
transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1.79);
}
.m3u_li:active>div:after{
opacity: 1;
content: "已複製";
position: absolute;
display: block;
font-size: 0.7em;
margin-top: 3px;
margin-left: 42px;
background-color: #9c9b9b;
line-height: 1em;
color: #FFF;
padding: 3px;
border-radius: 5px;
}
#ani-tab-content-3{ /*原本m3u8 */
display:none;
}
.m3u_bn{
height: 30px;
argin: 5px;
border: 1px solid #888;
border-radius: 5px;
background: #fff;
cursor: pointer;
outline: none;
background: none;
font-size: 1.3rem;
line-height: 27px;
padding: 0 10px;
}
</style>`);
})();
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers