// ==UserScript==
// @name 動漫瘋
// @namespace none
// @version 0.1
// @description 取得動漫瘋m3u8檔案,用potplayer觀看,加上很多問題
// @author sheepdragon
// @match http://ani.gamer.com.tw/animeVideo.php?sn=*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
$('iframe').eq(0).remove();
$('iframe').eq(1).remove();
$('iframe').eq(2).remove();
var block=setInterval(function(){
//document.getElementById('ani_video_html5_api').currentTime+=30;
if($('.vjs-playing').length===0){
console.log($('.vjs-playing').length);
}
else{
console.log('ADBLOCKS');
$('.vast-blocker').remove();
$('.whilebg').remove();
$('.vast-blocker').removeAttr('href');
$('.vast-blocker').removeAttr('target');
$('.vast-skip-button').attr("href","#");
$('.vast-skip-button').removeAttr("target");
$('#ani_video').removeClass('vjs-ad-playing');
$('#ani_video').attr({'data viblast av-gap-correction':false});
clearInterval(block);
}
},500);
$(document).ready(function() {
var snID=animefun.videoSn;
var deviceID,listSrc,Origin,Words=[],Player=[],resolution=['360p','540p','720p','1080p'];
$.getScript('https://clipboardjs.com/dist/clipboard.min.js', function (data, textStatus, jqxhr) {
//複製用JS
console.log('成功JS');
window.onload = function ()
{
checklock();
};
});
function checklock(){
//未知效果都是實驗中
$.ajax({
url: 'ajax/videoCastcishu.php?',
data: {'sn':snID,'s':getAd()[0],'ad':'end'},
type: "GET",
dataType: 'text',
success: function(msg) {
console.log('取得videoCastcishu');
one();
},
error: function(xhr, ajaxOptions, thrownError) {
console.log('videoCastcishu失敗');
}
});
}
function one(){
$.ajax({
url: 'https://licensing.viblast.com/licensing/rest/check/bth44tqf2a?',
data: {stream:"//gamer-cds.cdn.hinet.net/vod/gamer/gamer_ad-"+getAd()[0]+"/hls-ae-2s/index.m3u8"},
type: "POST",
dataType: 'json',
success: function(msg) {
two();
console.log('取得viblastAD');
},
error: function(xhr, ajaxOptions, thrownError) {
console.log('失敗viblastAD');
}
});
}
function two(){
$.ajax({
url: 'ajax/checklock.php?',
data: {sn:snID,device:deviceID},
type: "GET",
dataType: 'text',
success: function(msg) {
console.log('可使取得checklock');
three();
},
error: function(xhr, ajaxOptions, thrownError) {
console.log('解鎖checlock失敗');
}
});
}
function three(){
$.ajax({
url: 'ajax/videoCastcishu.php?',
data: {'sn':snID,'s':getAd()[0],'ad':'end'},
type: "GET",
dataType: 'text',
success: function(msg) {
console.log('取得videoCastcishuEND');
getDevice();
},
error: function(xhr, ajaxOptions, thrownError) {
console.log('videoCastcishuEND失敗');
}
});
}
function getDevice(){
$.ajax({
url: 'ajax/getdeviceid.php?',
data: {sn:snID},
type: "GET",
dataType: 'json',
success: function(msg) {
console.log('取得設備成功');
deviceID=msg.deviceid;
getM3u8();
},
error: function(xhr, ajaxOptions, thrownError) {
console.log('取得設備取得失敗');
}
});
}
function getM3u8(){
$.ajax({
url: 'ajax/m3u8.php?',
data: {'sn':snID,'device':deviceID},
type: "GET",
dataType: 'json',
success: function(msg) {
console.log('m3u8列表取得成功 :'+msg.src);
listSrc=msg.src;
getM3u8List();
},
error: function(xhr, ajaxOptions, thrownError) {
console.log('m3u8列表取得失敗');
}
});
}
function getM3u8List(){
$.ajax({
url: listSrc,
data: '',
type: "GET",
dataType: 'text',
success: function(msg) {
console.log('列表取得原始m3u8成功');
Origin=msg.split('\n');
if(Origin.length<20){
stringPlus();
}
else{
console.log('取得失敗請先點廣告');
}
},
error: function(xhr, ajaxOptions, thrownError) {
console.log('列表取得原始m3u8失敗');
}
});
}
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(){
var btns = document.querySelectorAll('button');
var clipboard = new Clipboard(btns);
clipboard.on('success', function(e) {
console.log(e);
});
clipboard.on('error', function(e) {
console.log(e);
});
$('.videoname').append("<div>"+((Origin.length-3)/2)+"種 解析度</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;
//console.log(id);
$('.videoname').append("<div>\
<button data-clipboard-demo data-clipboard-target='#"+id+"' style='margin: .5rem;display: inline-block;color: #00b4d8;line-height: 2rem;' data-clipboard-text='"+Link+"'>"+(!resolution[i]?'':resolution[i])+"</button>\
<div style='margin: .5rem;'>"+Link+"</div>\
</div>");
}
//console.log(Player);
}
});
})();