// ==UserScript== // @name 動漫瘋 // @namespace none // @version 0.96 // @description 取得動漫瘋m3u8檔案,用potplayer觀看,已經接近正式版 // @author sheepdragon // @match http://ani.gamer.com.tw/animeVideo.php?sn=* // @grant none // @icon https://i2.bahamut.com.tw/anime/baha_s.png // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Your code here... var snID = animefun.videoSn; var deviceID = animefun.getdeviceid() , listSrc, Origin, Words = [], Player = [],Info, ad= getAd()[0], sec= 15,secs= 15, max = 10 , now = 0, adID, resolution = ['360p', '540p', '720p', '1080p'], locked = true,hash; $(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 reGET( lock = false){ show('解鎖中...'); if( now < max ){ var viewsec=setInterval(function(){ if(sec==7 && now!==0){ show( '重試進度' + now + '/'+ max +'(' + (now/max)*100 +')%'); secs=7; } else if(now===0){ show(sec+'秒後取得'); } else{ show(sec+'秒後..重試'); } sec--; if(sec<=0){ sec=7; clearInterval(viewsec); } }, 1000); 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('播放小心廣告'); $('.bullet-send-tip').html('如果需要線上播放建議重新整理,無的話請使用使m3u8! 蜜柑?'); } }).catch(function(xhr, ajaxOptions, thrownError) { show('重新getM3u8Lists失敗'); }); } else{ now ++; show(now + '/'+ max +'(' + (now/max)*100 +')% 失敗'); reGET(false); } }).catch(function(xhr, ajaxOptions, thrownError) { show('取得重新getList失敗'); }); },secs*1000); } else{ show('放棄~失敗'); } } function show(msg = false) { console.log(msg); $('#error_msg').remove(); $('.sub_top').append('' + 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('' + $('.sub_top').html()); $('.sub_top').append('
'); $('#m3u8').append("