// ==UserScript==
// @name 動畫瘋·Plus
// @namespace none
// @version 1.15.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
// ==/UserScript==
(function() {
'use strict';
var ncc_warning_save = (GM_getValue("ncc_warning") != null )?GM_getValue("ncc_warning"): GM_setValue('ncc_warning','false');
var grading_save = (GM_getValue('grading_save') != null )?GM_getValue('grading_save'):GM_setValue('grading_save','none');
var video_next_skip = (GM_getValue('video_next') != null )?GM_getValue('video_next'):GM_setValue('video_next','false');
var password_save = GM_getValue('password_save');
var grading_bool = false,video_next_bool = false;
var deviceid = animefun.getdeviceid();
var sn = animefun.videoSn;
//檢查Beta播放器是否開啟
if(Cookies.get('player') == 'new') {
return //不執行以下程式碼
}
//使用者介面
var aniplusui_html = '<div class="ani-tabs__item">';
aniplusui_html+='<div onclick="$(this).plus_ui();" class="ani-tabs-link" style="cursor: pointer;">動畫瘋·Plus';
aniplusui_html+='<span class="plus_explain" style="position:absolute;z-index: 2;">';
aniplusui_html+='<span style="left: unset;line-height: 27px;position: fixed;right: 70px;">';
aniplusui_html+='Ver 1.15.2<br>此版本刪除分級鎖定,優化空降足跡功能。';
aniplusui_html+='</span></span></div></div>';
$('.sub_top').append(aniplusui_html);
$('.ani-tab-content').append('<div id="ani-tab-content" class="ani-tab-content__item" style="display: none;"></div>');
$.fn.plus_ui = function(){
$(".ani-tab-content__item").css("display","none");
$("#ani-tab-content").css("display","block");
$('.ani-tabs-link').removeClass('is-active');
$(this).addClass("is-active");
};
//使用者介面CSS
$('head').append(`
<style>
.plus_bullet-send {
padding:0 5px 0 5px;
width:20%;
z-index:1;
border-radius:5px;
cursor:all-scroll;
}
.plus_bullet-control {
left:unset;
right:0;
z-index:1;
height:100%;
}
.plus_bullet-send_icon {
width: 42px;
height: 40px;
float: right;
padding: 6px 8px;
border-style: none;
background-color: transparent;
color: #888;
}
.plus_bullet-send_icon:before {
content: "chat";
}
.plus_bullet-send_icon:before {
font-size: 26px;
direction: ltr;
display: inline-block;
font-family: 'Material Icons';
font-style: normal;
font-weight: normal;
letter-spacing: normal;
line-height: 1;
text-transform: none;
white-space: nowrap;
word-wrap: normal;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
-webkit-font-feature-settings: 'liga';
font-feature-settings: 'liga';
}
.plus_bullet-send_icon:hover{
color: #00B4D8;
}
.plus_Web_fullscreen_icon {
width: 42px;
height: 40px;
float: right;
padding: 6px 8px;
border-style: none;
background-color: transparent;
color: #888;
}
.plus_Web_fullscreen_icon:before {
content: "aspect_ratio";
}
.plus_Web_fullscreen_icon:before {
font-size: 26px;
direction: ltr;
display: inline-block;
font-family: 'Material Icons';
font-style: normal;
font-weight: normal;
letter-spacing: normal;
line-height: 1;
text-transform: none;
white-space: nowrap;
word-wrap: normal;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
-webkit-font-feature-settings: 'liga';
font-feature-settings: 'liga';
}
.plus_Web_fullscreen_icon:hover{
color: #00B4D8 !important;
}
.plus_time_body{
width: 100%;
padding: 8px;
min-height: 170px;
border: 1px solid #ddd;
background: #f5f5f5;
border-radius: 4px;
box-sizing: border-box;
}
.plus_keyword-label {
display: inline-flex;
align-items: center;
max-width: 100%;
margin: 0 4px 4px 0;
background: #02B4D8;
font-size: 13px;
color: #fff;
border-radius: 4px;
}
.plus_keyword-label > span {
display: block;
padding: 3px 6px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
vertical-align: middle;
}
.plus_k-label {
align-items: center;
max-width: 100%;
margin: 0 4px 4px 0;
padding: 3px 6px;
background: #02B4D8;
font-size: 13px;
color: #fff;
border-radius: 4px;
}
.plus_k-label > span {
display: none
}
.plus_k-label:hover span {
min-height: 20px;
width: 330px;
position: absolute;
z-index: 999;
padding: 10px;
display: block;
background-color:rgba(0, 0, 0, 0.86);
color: #ffffff;
border-radius: 5px;
font-size: 16px;
left: 50px;
}
.plus_explain {
font-size: 21px;
color: #888;;
float: right;
}
.plus_explain:before {
content: "help";
}
.plus_explain:before {
direction: ltr;
display: inline-block;
font-family: 'Material Icons';
font-style: normal;
font-weight: normal;
letter-spacing: normal;
line-height: 1;
text-transform: none;
white-space: nowrap;
word-wrap: normal;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
-webkit-font-feature-settings: 'liga';
font-feature-settings: 'liga';
}
.plus_explain > span {
display: none
}
.plus_explain:hover span {
min-height: 20px;
width: 330px;
position: absolute;
z-index: 999;
padding: 10px;
display: block;
background-color:rgba(0, 0, 0, 0.86);
color: #ffffff;
border-radius: 5px;
font-size: 16px;
left: 50px;
}
.plus_no_sub {
text-align: center;
line-height: 1.5em;
color: #888;
margin: 10px auto;
}
button.plus_refresh {
float: none;
margin: 0;
padding: 0;
height: 30px;
width: 30px;
border: 1px solid #ccc;
background: #eee;
font-size: 18px;
border-radius: 5px;
cursor: pointer;
outline: none;
}
.ani-tab-content__item .plus_refresh {
width: 30px;
height: 30px;
border: 1px solid #00B4D8;
background: #00B4D8;
color: #fff;
}
.ani-tab-content__item .plus_refresh:hover {
background: #FFF049;
border-color: #FFF049;
color: #333;
}
.plus_material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 21px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
font-feature-settings: "liga" 1;
}
.ani-tab-content__item .plus_refresh > i {
vertical-align: middle;
}
.video-next-button {
display: block;
position: absolute;
color: #fff;
background: #000;
text-decoration: none;
padding: 10px;
bottom: 40px;
right: 0px;
z-index: 10;
border-top: 1px solid #aaa;
border-left: 1px solid #aaa;
border-bottom: 1px solid #aaa;
font-size: 1.5em;
}
.plus_dialog-border{
border: 1px solid #599bdc;
position: absolute;
z-index: 1000;
background: white;
padding: 10px;
font-size: 1.3rem;
right: 15px;
}
/*分級鎖定介面CSS*/
.ani-select {
display: inline-block;
padding: 0 8px;
height: 30px;
border: 1px solid #ddd;
box-sizing: border-box;
border-radius: 4px;
font-size: 16px;
vertical-align: middle;
}
.plus-keyword-header {
display: flex;
}
.plus-keyword-header .plus-bluebtn {
flex: 0 0 auto;
position: relative;
display: inline-block;
padding: 6px 12px;
font-size: 13px;
border-radius: 4px;
vertical-align: middle;
}
.plus-bluebtn {
border-radius: 10px;
padding: 12px;
text-align: center;
text-decoration: none;
color: #fff;
margin: 0px 7px 0 0;
background: #00B4D8;
display: inline-block;
font-size: 1.3em;
}
.plus-bluebtn:disabled{
background-color:#ebebe4;
color: #757575;
}
.ani-select:disabled{
background-color:#ebebe4;
}
.plus-input {
display: inline-block;
margin: 0 8px 0 0;
padding: 0 8px;
height: 30px;
border: 1px solid #ddd;
box-sizing: border-box;
border-radius: 4px;
font-size: 16px;
vertical-align: middle;
width: 165px;
}
.plus-message {
z-index: 1000;
top: 310px;
width: 100%;
height: 538px;
padding: 10px;
background: #000000cf;
box-shadow: 0 0 5px 0px rgba(0, 0, 0, 0.2);
left: 0px !important;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
}
.plus-frame {
position: relative;
z-index: 72;
}
.pluss-bluebtn{
width: 55px;
height: 30px;
padding: 10px 12px;
font-size: 13px;
border-radius: 4px;
vertical-align: middle;
text-align: center;
text-decoration: none;
color: #fff;
background: #00B4D8;
}
.plus-box {
height: 100px;
background: #fff;
width: 415px;
display: flex;
justify-content: center;
align-items: center;
border-radius: 4px;
}
.plus-input.plus-input--keyword {
max-width: 300px;
margin: 0px 8px 0px 8px;
}
.plus-video-fastforward {
display: inline-block;
margin: 0 8px 0 0;
padding: 0 8px;
height: 30px;
border: 1px solid #ddd;
box-sizing: border-box;
border-radius: 4px;
font-size: 16px;
vertical-align: middle;
width: 71px;
}
</style>
`);
//使用者介面HTML
var ui_html = '<div class="ani-setting-section">';
ui_html += '<div id="plussetup" class="plus_dialog-border" style="display:none;">設定已儲存</div>';
ui_html += '<h4 class="ani-setting-title">動畫瘋·Plus <div class="plus_explain"><span>此插件設計是為了給短時間大量補番的人使用的,並加入一些沒用的功能<br>如果您覺得此插件好用,請付費支持動畫瘋讓此插件能持續為本平台服務</span></div></h4>';
ui_html += '<h4 class="ani-setting-title"><a href="https://chrome.google.com/webstore/detail/%E5%8B%95%E7%95%AB%E7%98%8B%C2%B7plus/jkpkmeimgkhodlppajjgikfcodlilmpd" target="_blank">在Chrome線上應用店中已發布相同的插件</a></h4>';
ui_html += '<div class="ani-setting-item ani-flex">';
ui_html += '<div class="ani-setting-label">';
ui_html += '<span class="ani-setting-label__mian">自動同意分級標識警告</span>';
ui_html += '</div>';
ui_html += '<div class="ani-setting-value ani-set-flex-right">';
ui_html += '<div class="ani-checkbox">';
ui_html += '<label class="ani-checkbox__label">';
ui_html += '<input id="grading" type="checkbox">';
ui_html += '<div class="ani-checkbox__button"></div>';
ui_html += '</label>';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '<div class="ani-setting-item ani-flex">';
ui_html += '<div class="ani-setting-label">';
ui_html += '<span class="ani-setting-label__mian">自動切換至下一集</span>';
ui_html += '</div>';
ui_html += '<div class="ani-setting-value ani-set-flex-right">';
ui_html += '<div class="ani-checkbox">';
ui_html += '<label class="ani-checkbox__label">';
ui_html += '<input id="video_next_skip" type="checkbox">';
ui_html += '<div class="ani-checkbox__button"></div>';
ui_html += '</label>';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '<div class="ani-setting-item ani-flex">';
ui_html += '<div class="ani-setting-label">';
ui_html += '<span class="ani-setting-label__mian">影片速度</span>';
ui_html += '</div>';
ui_html += '<div class="ani-setting-value ani-set-flex-right">';
ui_html += '<div class="ani-checkbox">';
ui_html += '<select id="void_speed" class="ani-select" disabled>';
ui_html += '<option value ="0.25">0.25</option>';
ui_html += '<option value ="0.5">0.5</option>';
ui_html += '<option value ="0.75">0.75</option>';
ui_html += '<option value ="1" selected>正常</option>';
ui_html += '<option value ="1.25">1.25</option>';
ui_html += '<option value ="1.5">1.5</option>';
ui_html += '<option value ="2">2</option>';
ui_html += '</select>';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '</div>';
/*
ui_html += '<div class="ani-setting-item ani-flex">';
ui_html += '<div class="ani-setting-label">';
ui_html += '<span id="plus-setting-label__mian" class="ani-setting-label__mian">分級鎖定</span>';
ui_html += '</div>';
ui_html += '<div id="plus-value" class="ani-setting-value ani-set-flex-right">';
ui_html += '<div class="plus-keyword-header">';
ui_html += '<input type="password" id="plus-password" class="plus-input ani-input--keyword" placeholder="首次使用須設定密碼">';
ui_html += '<a id="plus-password-setup" href="#" role="button" class="plus-bluebtn" >設定</a>';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '<div id="plus-value2" class="ani-setting-value ani-set-flex-right" style="display:none">';
ui_html += '<div class="plus-keyword-header">';
ui_html += '<input type="password" id="plus-password2" class="plus-input ani-input--keyword" placeholder="輸入密碼">';
ui_html += '<a id="plus-password-enter-setup" href="#" role="button" class="plus-bluebtn" >確定</a>';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '<div id="ncc-password" class="ani-setting-value ani-set-flex-right" style="display:none">';
ui_html += '<div class="ani-checkbox">';
ui_html += '<select id="grading-password" class="ani-select">';
ui_html += '<option value ="none" selected>無</option>';
ui_html += '<option value ="6">保護級(含·以上)</option>';
ui_html += '<option value ="12">補12級(含·以上)</option>';
ui_html += '<option value ="15">補15級(含·以上)</option>';
ui_html += '<option value ="18">限制級</option>';
ui_html += '</select>';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '</div>';
*/
ui_html += '<div class="ani-setting-item ani-flex">';
ui_html += '<div class="ani-setting-label">';
ui_html += '<span class="ani-setting-label__mian">空降座標</span>';
ui_html += '</div>';
ui_html += '<div class="ani-setting-value ani-set-flex-right">';
ui_html += '<div class="plus-keyword-header">';
ui_html += '<input type="text" id="plus-video-fastforward-minute" class="plus-video-fastforward ani-input--keyword" disabled placeholder="00" onKeypress="if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;">:';
ui_html += '<input type="text" id="plus-video-fastforward-second" class="plus-video-fastforward ani-input--keyword" disabled placeholder="00" onKeypress="if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;">';
ui_html += '<input id="plus-video-fastforward-sendout" class="plus-bluebtn" value="降落" disabled type="submit" style="border:2px blue none;">';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '<div class="ani-setting-item">';
ui_html += '<div class="ani-setting-label">';
ui_html += '<span class="ani-setting-label__mian">空降足跡<font size="2">(點擊降落)</font></span>';
ui_html += '<span class="plus_explain"><span>說明:<br>運作原理是取所有彈幕文字並利用關鍵字篩選<br>如果有在自訂過濾關鍵字新增"空降"or"座標"和開啟自動過濾<br>結果會不同</span></span>';
ui_html += '<div class="ani-setting-value ani-set-flex-right">';
ui_html += '<span class="plus_k-label">確認座標<span>說明:已回報的座標</span></span>';
ui_html += '<span class="plus_k-label" style="background:#bbbbbb;">其它座標<span>說明:<br>其它座標又稱未確定座標,有可能的原因是紀念觀賞時間<br>或未放入"空降"or"座標"關鍵字</span></span>';
ui_html += '<button class="plus_refresh"><i class="plus_material-icons">refresh</i></button>';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '<div class="plus_time_body">';
ui_html += '<ul class="plus_no_sub"><img src="https://i2.bahamut.com.tw/anime/no_sub.png"style="width: 33%;"><br>正在努力尋找中···</ul>';
ui_html += '</div>';
ui_html += '</div>';
ui_html += '</div>';
$("#ani-tab-content").append(ui_html);
//網頁全螢幕
window.Webfullscreen = setInterval(function(){
if($(".R18").length == 0 && $(".plus-frame").length == 0){
let webfullscreen_h = '<button onclick="$(this).web_fullscreen();" class="plus_Web_fullscreen_icon vjs-control vjs-show-tip" type="button" aria-disabled="false" title="網頁全螢幕" ></button>';
$(".vjs-fullscreen-control").after(webfullscreen_h);
clearInterval(window.Webfullscreen);
}
},1000);
var webfullscreen_s = true;
$.fn.web_fullscreen = function(){
let win_height = $(window).height();
let win_width = $(window).width();
if(webfullscreen_s){
webfullscreen_s = false;
$("body").after('<div id="Web_fullscreen_style"></div>');
$("#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{
webfullscreen_s = 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 && !webfullscreen_s){
webfullscreen_s = 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(!webfullscreen_s){
let win_height = $(window).height();
$(".videoframe").css("height",(win_height-40)+"px");
}
});
//網頁全螢幕CSS
$('#Web_fullscreen_style').append(`
<style>
.container-player {
max-width: unset !important;
}
.player {
padding-top: 0 !important;
margin-top: 0 !important;
z-index: 999 !important;
position: fixed !important;
}
.videoframe {
width: 100% !important;
height: `+(win_height-40)+`px;
margin: auto !important;
}
.video {
width: 100% !important;
height: 100% !important;
position: unset !important;
padding-bottom: unset !important;
}
.BH_background {
margin-top: unset !important;
position: relative position: fixed
}
@media (min-width: 1000px)
.BH_background {
margin-top: unset !important;
}
.sky {
display: none !important;
}
.mainmenu {
display: none !important;
}
.subtitle {
display: none !important;
}
</style>
`);
};
//在全螢幕環境下發送彈幕
$(document).on("mozfullscreenchange webkitfullscreenchange fullscreenchange", fullscreenChange);
function fullscreenChange(){
let isFullScreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
let fullScreen_bullet_send = '<button id="plus_fullScreen-bullet-send" class="plus_bullet-send_icon vjs-control vjs-button vjs-show-tip" type="button" aria-disabled="false" title="發送彈幕 左右兩側可以拖移輸入框"';
fullScreen_bullet_send += 'onclick="$(\'#plus_bullet-send\').slideToggle(0);"><span aria-hidden="true" class="vjs-icon-placeholder"></span><span class="vjs-control-text" aria-live="polite"></span></button>';
if(isFullScreen){
plus_bullet_control();
plus_bullet_save();
$('#danmutxt').keydown(function(event){
event.stopPropagation();
});
$(".vjs-danmu-button").after(fullScreen_bullet_send);
$(".plus_Web_fullscreen_icon").css("display","none");
$(".bullet-send").draggable({
containment: "html",
stop: function () {
let top = $("#plus_bullet-send").css("top");
let win_height = $(window).height();
if(parseInt(top) > (win_height - 100)){
$("#plus_bullet-send").css("top",(win_height - 100));
}
let top_save = $("#plus_bullet-send").css("top");
let left_save = $("#plus_bullet-send").css("left");
GM_setValue('top_save',top_save);
GM_setValue('left_save',left_save);
}
});
$("input[type='button']").click(function(){
$("#plus_bullet-control").css("display","none");
$("#danmutxt").focus();
});
}else{
$("#plus_bullet-send").remove();
$("#plus_bullet-control").remove();
$(".bullet-control").css("display","none");
$(".plus_Web_fullscreen_icon").css("display","");
$("#plus_fullScreen-bullet-send").remove();
}
}
function plus_bullet_control(){
let bullet_send = '<div class ="bullet-send" id="plus_bullet-send" style="display:none; box-shadow: rgba(0, 0, 0, 0.19) 0px 0px 3px 1px;">'+$(".bullet-send").html()+'</div>';
let bullet_control = '<div class ="bullet-control" id="plus_bullet-control" style="display: none;">'+$(".bullet-control").html()+'</div>';
$("video").after(bullet_send);
$("video").after(bullet_control);
$("#plus_bullet-send").addClass("plus_bullet-send");
$("#plus_bullet-control").addClass("plus_bullet-control");
}
function plus_bullet_save(){
let top_save = GM_getValue("top_save")
let left_save = GM_getValue("left_save")
if(top_save == null || left_save == null ){
$("#plus_bullet-send").css("top","0px");
$("#plus_bullet-send").css("left","0px");
GM_setValue('top_save',"0px");
GM_setValue('left_save',"0px");
}else{
$("#plus_bullet-send").css("top",top_save);
$("#plus_bullet-send").css("left",left_save);
}
}
//偵測分級標識警告&廣告狀態
setTimeout(function(){
window.initial = setInterval(function(){
let src = $("#ani_video_html5_api").attr("src");
let readyState = $("#ani_video_html5_api")[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(){
let ended = $("#ani_video_html5_api")[0].ended;
let nextplayer = $('.playing').next().html();
let match = (nextplayer!=null)?nextplayer.match('<a href="(.*)">')[1]:null;
if(match != null){video_next();}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");
danmuGetload();
clearInterval(window.initial);
}else{
$(".plus_keyword-label").css("cursor","no-drop");
}
},1000);
},1000);
//自動切換至下一集
$("#video_next_skip").change(function() {
video_next_bool = !video_next_bool;
GM_setValue('video_next',video_next_bool);
$("#plussetup").css("display","block");
setTimeout(function(){$("#plussetup").css("display","none")},3000);
});
if(video_next_skip){
video_next_bool = true;
$("#video_next_skip").prop("checked",true);
setTimeout(function(){$("#ani_video").append('<div class="video-next-button" id="ani_video-next" style="display:none"></div>')},1000);
}
var countdown = 5;
function video_next(){
let ended = $("#ani_video_html5_api")[0].ended;
let nextplayer = $('.playing').next().html();
let match = (nextplayer!=null)?nextplayer.match('<a href="(.*)">')[1]:null;
if(ended && match != null){
if(countdown == 1)document.location.href="https://ani.gamer.com.tw/animeVideo.php"+match
$("#ani_video-next").css("display",'unset');
$("#ani_video-next").html('0'+countdown+' 秒後切換至下一集<span id="stop_video-next" style="cursor:pointer"> X</span>');
countdown -= 1;
}else{
$("#ani_video-next").css("display",'none');
countdown = 5;
}
$("#stop_video-next").click(function(){$("#ani_video-next").remove();clearInterval(window.videoend);});
}
//自動同意分級標識警告
$("#grading").change(function() {
grading_bool = !grading_bool;
GM_setValue('ncc_warning',grading_bool);
$("#plussetup").css("display","block");
setTimeout(function(){$("#plussetup").css("display","none")},3000);
});
if(ncc_warning_save){
grading_bool = true;
let rating_img = $(".rating > img").attr("src");
let img_cut = rating_img.substr(30);
$("#grading").prop("checked",true);
window.ncc = setInterval(function(){
if($(".R18").length > 0 && $(".plus-frame").length == 0){
if(img_cut != 'TW-18UP.gif'|| token()[1] == 1){
$("#adult").click();
}
clearInterval(window.ncc);
}
},1000);
}
//空降座標
$('#plus-video-fastforward-sendout').on('click', function() {
var minute = $("#plus-video-fastforward-minute").val();
var second = $("#plus-video-fastforward-second").val();
$("#plus-video-fastforward-minute").val("");
$("#plus-video-fastforward-second").val("");
if($("#ani_video_html5_api")[0].paused != true){$(".vjs-play-control").click();}
fastforward(minute,second);
});
//改變影片時間
function fastforward(minute,second){
let video_minute = parseInt(minute) || 0;
let video_second = parseInt(second) || 0;
if((video_minute*60) + video_second < $("#ani_video_html5_api")[0].duration){
$("#ani_video_html5_api")[0].currentTime = (video_minute*60) + video_second;
if($("#ani_video_html5_api")[0].paused == true){$(".vjs-play-control").click();}
}else{
if($("#ani_video_html5_api")[0].paused == true){$(".vjs-play-control").click();}
alert("未知的座標,空降失敗");
}
}
//空降足跡-解析影片時間
function time_parse(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 danmuGet(){
var array= [];
var settings = {
"async": true,
"crossDomain": true,
"url": "ajax/danmuGet.php",
"method": "POST",
"data": {
"sn": animefun.videoSn
}
}
$.ajax(settings).done(function (response) {
$(".plus_time_body").children().remove();
for(var key in response){
let stringasc = tobig5(response[key].text);
let match = stringasc.match(/[0-9]{1,3}:[0-9]{1,3}/g);
if( stringasc.indexOf("空降") != "-1" || stringasc.indexOf("座標") != "-1"){
time_parse(stringasc,array,true);
}else if(match){
time_parse(stringasc,array,false);
}
}
var deduped = filter_r(array,'time'); //清除重複
var json = jsonsort(deduped,'time'); //排序
if(json.length){
for(var arrayid in json){
let airborne = (json[arrayid].airborne)?"":"background:#bbbbbb;"
$(".plus_time_body").append('<span class="plus_keyword-label" style="cursor:pointer;'+airborne+'"><span onclick="$(this).fastforward_skip(\''+json[arrayid].time+'\')">'+json[arrayid].time+'</span></span>');
}
}else{
$(".plus_time_body").html('<ul class="plus_no_sub"><img src="https://i2.bahamut.com.tw/anime/no_sub.png"style="width: 33%;"><br>目前沒有人嘗試空降<br>發個彈幕報告空降座標吧!</ul>')
}
});
}
//空降足跡-改變影片時間
$.fn.fastforward_skip = function (match){
let src = $("#ani_video_html5_api").attr("src");
let readyState = $("#ani_video_html5_api")[0].readyState;
if($(".R18").length == 0 && $(".vast-skip-button").length == 0 && src.indexOf("fbcdn.net") == -1 && readyState != 0){
if($("#ani_video_html5_api")[0].paused != true){$(".vjs-play-control").click();}
let split = match.split(":");
fastforward(split[0],split[1]);
}
}
function danmuGetload() {
setTimeout(function () {
danmuGet();//載入空降足跡
//空降足跡重整
$(".plus_refresh,#bahablack,.bluebtn").click(function () {
setTimeout(function () { danmuGet() }, 1000)
});
}, 1000)
}
//用戶狀態
function token(){
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];
}
//文字半形全形轉換
function tobig5(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_r(arr,attr){
var tmp = {},re = [],len = arr.length;
for(var i=0;i<len;i++){
if(!(arr[i][attr] in tmp)) re.push(arr[i]);
tmp[arr[i][attr]] = 1;
}
return re;
}
//json排序
function jsonsort(json,key){
for(var j=1; j < json.length; j++){
var temp = json[j],val = temp[key],i = j-1;
while(i >=0 && json[i][key]>val){
json[i+1] = json[i];
i = i-1;
}
json[i+1] = temp;
}
return json;
}
})();