// ==UserScript==
// @name 動畫瘋·Plus
// @namespace none
// @version 1.13.2
// @description 分級標識自動同意、自動切換至下一集、分級鎖定、影片空降座標、網頁全螢幕
// @author xu3u04u48
// @match *://ani.gamer.com.tw/animeVideo.php?sn=*
// @icon https://i2.bahamut.com.tw/anime/baha_s.png
// @require https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js
// @grant GM_setValue
// @grant GM_getValue
// @run-at document-end
// @downloadURL none
// ==/UserScript==
//使用者介面
$('.sub_top').append('
');
$('.ani-tab-content').append('');
$('a[href="#ani_tab_content-3"]').click(function(){
$(".ani-tab-content__item").css("display","none");
$("#ani-tab-content-3").css("display","block");
$('.ani-tabs-link').removeClass('is-active');
$(this).addClass("is-active");
});
//使用者介面CSS
$('head').append(`
`);
//使用者介面HTML
$("#ani-tab-content-3").prepend(`
動畫瘋·Plus
影片速度
分級鎖定
空降足跡(點擊降落)
?說明:
運作原理是取所有彈幕文字並利用關鍵字篩選
如果有在自訂過濾關鍵字新增"空降"or"座標"和開啟自動過濾
結果會不同
確認座標說明:已回報的座標
其它座標說明:
其它座標又稱未確定座標,有可能的原因是紀念觀賞時間
或未放入"空降"or"座標"關鍵字
`);
//分級鎖定介面HTML
$('.video').append(`
`);
//分級鎖定介面CSS
$('head').append(`
`);
//網頁全螢幕
var Switch = true;
window.qtimer = setInterval(function(){
if($(".R18").length == 0 && $(".plus-frame").length == 0){
$(".vjs-fullscreen-control").after('');
clearInterval(window.qtimer);
}
$("#Web_fullscreen").click(function(){
if(Switch){
Switch = false;
var win_height = $(window).height();
var win_width = $(window).width();
$("body").after('');
$("#animeTip").css("bottom","-40px");
$("html").css({"overflow-y":"hidden","overflow-x":"hidden"});
$(".vjs-indent-button").css("display","none");
$(".plus_Web_fullscreen_icon").css({"color":"#fff","background":"#333"});
$(".vjs-danmu").css("perspective","805.536px");
}else{
Switch = true;
$("#Web_fullscreen_style").remove();
$("#animeTip").css("bottom","0px");
$("html").css({"overflow-y":"unset","overflow-x":"unset"});
$(".videoframe").css({"height":"","width":"","margin":""});
$(".vjs-indent-button").css("display","unset");
$(".plus_Web_fullscreen_icon").css({"color":"","background":""});
$(".vjs-danmu").css("perspective","401.09px");
}
$(document).keydown(function(e) {
if(e.keyCode == 27 && !Switch){
Switch = true;
$("#Web_fullscreen_style").remove();
$("#animeTip").css("bottom","0px");
$("html").css({"overflow-y":"unset","overflow-x":"unset"});
$(".videoframe").css({"height":"","width":"","margin":""});
$(".vjs-indent-button").css("display","unset");
$(".plus_Web_fullscreen_icon").css({"color":"","background":""});
$(".vjs-danmu").css("perspective","");
}
});
$(window).resize(function() {
if(!Switch){
var win_height = $(window).height();
$(".videoframe").css("height",(win_height-40)+"px");
}
});
//網頁全螢幕CSS
$('#Web_fullscreen_style').append(`
`);
});
},2000);
var ncc_warning_save = GM_getValue("ncc_warning");
var password_save = GM_getValue('password_save');
var grading_save = GM_getValue('grading_save');
var video_next_skip = GM_getValue('video_next');
if(ncc_warning_save == null)ncc_warning_save = GM_setValue('ncc_warning','false');
if(grading_save == null)grading_save = GM_setValue('grading_save','none');
if(video_next_skip == null)video_next_skip = GM_setValue('video_next','false');
var grading_bool = false,video_next_bool = false;
var sn = animefun.videoSn,deviceid = animefun.getdeviceid();
$("#video_next_skip").change(function() {
GM_setValue('video_next',!video_next_bool);
video_next_bool = !video_next_bool;
});
function vl(){
var vip,login;
$.ajax({
url: 'ajax/token.php',
data: { sn: sn, device: deviceid},
type: "GET",
async: false,
success: function(t) {
var e = jQuery.parseJSON(t);
vip = e.vip;
login = e.login;
}
});
return [vip,login];
}
$("#grading").change(function() {
GM_setValue('ncc_warning',!grading_bool);
grading_bool = !grading_bool;
});
if(ncc_warning_save){
grading_bool = true;
$("#grading").prop("checked",true);
window.ncc = setInterval(function(){
if($(".ncc-choose-btn").length > 0 && $(".plus-frame").length == 0){
$("#adult").click();
clearInterval(window.ncc);
}
},1000);
}
//影片速度
$("#void_speed").change(function(){
var void_speed = $("#void_speed").find(":selected").val();
$("#ani_video_html5_api").get(0).playbackRate = void_speed;
});
//自動切換至下一集
if(video_next_skip){
video_next_bool = true;
$("#video_next_skip").prop("checked",true);
setTimeout(function(){$("#ani_video").append('')},1000);
}
var te = 5;
function t(){
var ended = $("#ani_video_html5_api").get(0).ended;
if(ended){
if(!te)document.location.href="https://ani.gamer.com.tw/animeVideo.php?sn="+animefun.nextSn
$("#ani_video-next").css("display",'unset');
$("#ani_video-next").html('0'+te+' 秒後切換至下一集 X');
te-=1;
}else{
$("#ani_video-next").css("display",'none');
te = 5;
}
$("#stop_video-next").click(function(){$("#ani_video-next").remove();clearInterval(window.videoend);});
}
setTimeout(function(){
window.initial = setInterval(function(){
var src = $("#ani_video_html5_api").attr("src");
var readyState = $("#ani_video_html5_api").get(0).readyState;
if($(".R18").length == 0 && $(".vast-skip-button").length == 0 && src.indexOf("fbcdn.net") == -1 && readyState != 0){
if(video_next_skip){
window.videoend = setInterval(function(){if(animefun.nextSn!=0){t()}else{clearInterval(window.videoend);}},1000)
}
$("#plus-video-fastforward-minute").attr("disabled",false);
$("#plus-video-fastforward-second").attr("disabled",false);
$("#plus-video-fastforward-sendout").attr("disabled",false);
$("#void_speed").attr("disabled",false);
$(".plus_keyword-label").css("cursor","pointer");
clearInterval(window.initial);
}else{
$(".plus_keyword-label").css("cursor","no-drop");
}
},1000);
},1000);
function fastforward(minute,second){
var video_minute = parseInt(minute) || 0;
var video_second = parseInt(second) || 0;
if((video_minute*60) + video_second < $("#ani_video_html5_api").get(0).duration){
$("#ani_video_html5_api").get(0).currentTime = (video_minute*60) + video_second;
}else{
alert("未知的座標,空降失敗");
}
}
$('#plus-video-fastforward-sendout').on('click', function() {
var minute = $("#plus-video-fastforward-minute").val();
var second = $("#plus-video-fastforward-second").val();
fastforward(minute,second);
$("#plus-video-fastforward-minute").val("");
$("#plus-video-fastforward-second").val("");
});
function Asc(obj){
var text = obj;
var asciiTable = "!\"#$%&\’()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
var big5Table = "%uFF01%u201D%uFF03%uFF04%uFF05%uFF06%u2019%uFF08%uFF09%uFF0A%uFF0B%uFF0C%uFF0D%uFF0E%uFF0F%uFF10%uFF11%uFF12%uFF13%uFF14%uFF15%uFF16%uFF17%uFF18%uFF19%uFF1A%uFF1B%uFF1C%uFF1D%uFF1E%uFF1F%uFF20%uFF21%uFF22%uFF23%uFF24%uFF25%uFF26%uFF27%uFF28%uFF29%uFF2A%uFF2B%uFF2C%uFF2D%uFF2E%uFF2F%uFF30%uFF31%uFF32%uFF33%uFF34%uFF35%uFF36%uFF37%uFF38%uFF39%uFF3A%uFF3B%uFF3C%uFF3D%uFF3E%uFF3F%u2018%uFF41%uFF42%uFF43%uFF44%uFF45%uFF46%uFF47%uFF48%uFF49%uFF4A%uFF4B%uFF4C%uFF4D%uFF4E%uFF4F%uFF50%uFF51%uFF52%uFF53%uFF54%uFF55%uFF56%uFF57%uFF58%uFF59%uFF5A%uFF5B%uFF5C%uFF5D%uFF5E";
var result = "";
for (var i = 0; i < text.length; i++) {
var val = escape(text.charAt(i));
var j = big5Table.indexOf(val);
result += (((j > -1) && (val.length == 6)) ? asciiTable.charAt(j / 6) : text.charAt(i));
}
return result;
}
//json清除重複
function filter(arr,attr){
var tmp = {},re = [],len = arr.length;
for(var i=0;i=0 && json[i][key]>val){
json[i+1] = json[i];
i = i-1;
}
json[i+1] = temp;
}
return json;
}
//空降足跡解析影片時間
function f(stringasc,array,bool){
var match = stringasc.match(/[0-9]+:[0-9]+/g);
for(var id in match){
var split = match[id].split(":");
var match1 = split[0].match(/[0-9]{2,3}/g),match2 = split[1].match(/[0-9]{2,3}/g);
var minute = (!match1)? "0"+split[0]:split[0], second = (!match2)? "0"+split[1]:split[1];
var addjson = {"airborne":bool,"time":minute+":"+second};
array.push(addjson);
}
}
function fastforward_skip(match,key){
$("#fastforward_id_"+key).click(function(){
var src = $("#ani_video_html5_api").attr("src");
var readyState = $("#ani_video_html5_api").get(0).readyState;
if($(".R18").length == 0 && $(".vast-skip-button").length == 0 && src.indexOf("fbcdn.net") == -1 && readyState != 0){
var split = match.split(":");
fastforward(split[0],split[1]);
}
});
}
//空降足跡
function danmuGet(){
var array= [];
var settings = {
"async": true,
"crossDomain": true,
"url": "https://ani.gamer.com.tw/ajax/danmuGet.php",
"method": "POST",
"data": {
"sn": animefun.videoSn
}
}
$.ajax(settings).done(function (response) {
for(var key in response){
var stringasc = Asc(response[key].text);
var a = stringasc.match(/[0-9]{1,3}:[0-9]{1,3}/g);
if( stringasc.indexOf("空降") != "-1" || stringasc.indexOf("座標") != "-1"){
f(stringasc,array,true);
}else if(a){
f(stringasc,array,false);
}
}
var deduped = filter(array,'time') //清除重複
var json = JsonSort(deduped,'time') //排序
if(json.length){
for(var arrayid in json){
if(json[arrayid].airborne){
$(".plus_time_body").append(''+json[arrayid].time+'')
}else{
$(".plus_time_body").append(''+json[arrayid].time+'')
}
fastforward_skip(json[arrayid].time,arrayid);
}
}else{
$(".plus_time_body").html('
目前沒有人嘗試空降
發個彈幕報告空降座標吧!
')
}
});
}
//延遲載入1秒
setTimeout(function(){
//載入空降足跡
danmuGet();
//空降足跡重整
$(".plus_refresh,#bahablack").click(function(){
$(".plus_keyword-label").remove();
danmuGet();
console.log("111");
});
},1000)
//分級鎖定功能
if(password_save != null ){
$("#plus-value").remove();
$("#plus-value2").css("display",'unset');
}
if(grading_save == null){
$(".plus-frame").remove();
}
var grading_selected = $('#grading-password').val(grading_save);
if($('#grading-password').val() != "none"){
var rating_img = $(".rating > img").attr("src");
var img_cut = rating_img.substr(30);
var a = ['TW-ALL.gif','TW-6TO12.gif','TW-12TO18.gif','TW-18UP.gif']
$(".plus-frame").css("display",'unset');
switch (grading_save) {
case '6' : if(img_cut == a[0])$(".plus-frame").remove();break;
case '12' : if(img_cut == a[0]|| img_cut == a[1])$(".plus-frame").remove();break;
case '15' : if(img_cut == a[0] || img_cut == a[1] || img_cut == a[2])$(".plus-frame").remove();break;
case '18' : if(img_cut != a[3])$(".plus-frame").remove();break;
}
}else{
$(".plus-frame").remove();
}
var grading = $("#grading-password").find(":selected").val();
$("#grading-password").change(function(){
grading = $("#grading-password").find(":selected").val();
GM_setValue('grading_save',grading);
});
//首次設定密碼
$('#plus-password-setup').on('click', function() {
var first_time_password = $("#plus-password").val();
var password_save = GM_getValue('password_save');
if(first_time_password != "" ){
$("#plus-value").remove();
$("#plus-value2").css("display",'unset');
GM_setValue('password_save',btoa(first_time_password));
}else{
alert("請輸入密碼");
}
});
//輸入密碼設定
$('#plus-password-enter-setup').on('click', function() {
var enter_password_setting = $("#plus-password2").val();
if(!enter_password_setting){
alert("請輸入密碼");
}else {
var password_save = GM_getValue('password_save');
if(password_save == btoa(enter_password_setting)){
$("#plus-value2").remove();
$("#ncc-password").css("display",'unset');
}else{
alert("密碼錯誤");
}
}
});
//輸入密碼解除
$('#plus-password-enter').on('click', function() {
var enter_the_password = $("#plus-password3").val();
var password_save = GM_getValue('password_save');
if(!enter_the_password){
alert("請輸入密碼");
}else if(password_save == btoa(enter_the_password)){
$(".plus-frame").remove();
}else{
alert("密碼錯誤");
}
});
//添加分級圖片
var rating_img1 = $(".rating > img").attr("src");
$('.plus-box').prepend('
');