動畫瘋·Plus

分級標識自動同意、自動切換至下一集、自動點此跳過廣告、影片空降座標、網頁全螢幕、子母畫面

目前为 2020-05-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         動畫瘋·Plus
// @namespace    https://home.gamer.com.tw/homeindex.php?owner=xu3u04u48
// @version      1.20.5
// @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';

    blockalert("廣告");
    var fun ={'ncc_warning':false,'video_next':true,'ad_skip':true};
    var ncc_warning_save = GM_getValue('ncc_warning') == undefined ? fun.ncc_warning : GM_getValue('ncc_warning');
    var video_next_skip = GM_getValue('video_next') == undefined ? fun.video_next : GM_getValue('video_next');
    var ad_skip_save = GM_getValue('ad_skip') == undefined ? fun.ad_skip : GM_getValue('ad_skip');

    var deviceid = animefun.getdeviceid();
    var sn = animefun.videoSn;
    var token = Token();





    //使用者介面
    var version = GM_info.script.version;
    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: inherit;right: 0px;top: 30px;cursor: initial;">';
    aniplusui_html+='Ver '+version+'<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: 35px;
height: 38px;
float: right;
padding: 6px 8px;
border-style: none;
background-color: transparent;
color: #fff;
opacity: 0.7;
}

.plus_bullet-send_icon:before {
content: "chat";
}

.plus_bullet-send_icon:before {
font-size: 19px !important;
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{
opacity: 1;
}


.plus_Web_fullscreen_icon {
width: 35px;
height: 38px;
float: right;
padding: 6px 8px;
border-style: none;
background-color: transparent;
color: #fff;
opacity: 0.7;
}

.plus_Web_fullscreen_icon:before {
content: "aspect_ratio";
}

.plus_Web_fullscreen_icon:before {
font-size: 19px !important;
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{
opacity: 1;
}

.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;
}

.plus_picture_in_picture_icon {
width: 35px;
height: 38px;
float: right;
padding: 6px 8px;
border-style: none;
background-color: transparent;
color: #fff;
opacity: 0.7;
}
.plus_picture_in_picture_icon:before {
content: "branding_watermark";
}
.plus_picture_in_picture_icon:before {
font-size: 19px !important;
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_picture_in_picture_icon:hover {
opacity: 1;
}

/*分級鎖定介面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;
}

.v_danmu_box{
position: absolute;
background-color: #292929ed;
border-radius: 4px;
width: 295px;
height: 40px;
margin: 0px 5px 0px 0px;
font-size: 12px;
}

.v_danmu_text{
float: left;
height: inherit;
line-height: 42px;
padding: 0px 15px;
max-width: 180px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
background-color: #ffffff00;
border: none;
color: white;
}

.v_danmu_menu{
border-radius: 5px;
width: 56px;
height: 28px;
line-height: 28px;
margin: 7px 0;
text-align: center;
color: #fff;
cursor: pointer;
float: right;
padding: 0;
}
</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 id="firefox_w" 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 += '<label class="ani-checkbox__label">';
    ui_html += '<input id="ad_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="plus-keyword-header">';
    ui_html += '<input type="text" id="danmu_key"  readonly="readonly" class="plus-video-fastforward ani-input--keyword" event.returnValue = false;">';
    ui_html += '<input id="danmu_key_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 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);

    var Firefox_w = '<span class="plus_explain"><span>因Firefox瀏覽器的政策【禁止自動播放聲音】,如果啟動此選項後無法正常播放影片<br>';
    Firefox_w +='請在瀏覽器權限【防止網站自動播放聲音】將【ani.gamer.com.tw】加入例外網站</span></span>';
    if(BrowserCheck("Firefox")[0] != null )$("#firefox_w").after(Firefox_w);


    //網頁全螢幕
    window.Webfullscreen = setInterval(function(){
        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>';
        if($(".control-bar-rightbtn").length == 1 && $(".plus_Web_fullscreen_icon").length == 0){
            $(".vjs-fullscreen-control").after(webfullscreen_h);
        }else if($(".plus_Web_fullscreen_icon").length == 1){
            clearInterval(window.Webfullscreen);
        }
    },500);

    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");
            $(".vjs-danmu").css("perspective","805.536px");
            $(".videoframe").css("height", win_height + "px");
        }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");
            $(".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");
                $(".vjs-danmu").css("perspective","");
            }
        });

        $(window).resize(function() {
            if(!webfullscreen_s){
                let win_height = $(window).height();
                $(".videoframe").css("height",win_height+"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;
margin: auto !important;
max-height: unset !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;
}

.top_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;
        setTimeout(function () {
            if (isFullScreen) {
                $(".plus_Web_fullscreen_icon").css("display", "none");
                $(".plus_picture_in_picture_icon").css("display", "none");
            } else {
                $(".plus_Web_fullscreen_icon").css("display", "");
                $(".plus_picture_in_picture_icon").css("display", "");
            }
        },500);
    }

    //偵測分級標識警告&廣告狀態
    setTimeout(function(){
        window.initial = setInterval(function(){
            if ($("#ani_video_html5_api")[0] == null) return;
            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){
                $("#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);
                if(video_next_skip){video_ended();}
                danmuGetload();
                video_danmun();
                clearInterval(window.initial);
            }
        },1000);
    },1000);



    var countdown = 5;
    var repeate = true //防止計時器重複執行

    //自動切換至下一集
    $("#video_next_skip").change(function() {
        GM_setValue('video_next',$(this).prop("checked"));
        $("#plussetup").css("display","block");
        setTimeout(function(){$("#plussetup").css("display","none")},3000);
    });

    if(video_next_skip){
        $("#video_next_skip").prop("checked",true);
        window.next_button = setInterval(function () {
            if($("#ani_video-next").length == 0){
                $("#ani_video").append('<div class="video-next-button" id="ani_video-next" style="display:none"></div>');
            }else{
                clearInterval(window.next_button);
            }
        },1000);
    }

    function video_ended(){
        $("#ani_video-next").html('<p class="vast-skip-button-text" id="video_next_countdown" style="float: left;"></p><p id="stop_video-next" style="cursor:pointer;float: left;padding: 0 0 0 10px;">X</p>');
        $("#ani_video_html5_api").on( 'ended', function() {
            countdown = 5;
            let nextplayer = $('.playing').next().html();
            let match = (nextplayer != null) ? nextplayer.match('<a href="(.*)">')[1] : null;
            if(match != null && repeate){
                video_next();
                repeate = false;
            }
        });
        $("#stop_video-next").click(function () {
            repeate = true;
            $("#ani_video-next").css("display", 'none');
            clearInterval(window.videoend);
        });

    }

    function video_next(){
        window.videoend = window.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 (ended && match != null) {
                $("#ani_video-next").css("display", '');
                $("#video_next_countdown").text(countdown.toString().padStart(2, "0") + " 秒後切換至下一集");
                if (countdown == 1){
                    document.location.href = "https://ani.gamer.com.tw/animeVideo.php" + match
                }else if (countdown < 1){
                    countdown = 1;
                    $("#ani_video-next").css("display", 'none');
                }
                countdown -= 1;
            } else {
                repeate = true;
                $("#ani_video-next").css("display", 'none');
                clearInterval(window.videoend);
            }
        }, 1000)
    }

    //自動同意分級標識警告
    $("#grading").change(function() {
        GM_setValue('ncc_warning',$(this).prop("checked"));
        $("#plussetup").css("display","block");
        setTimeout(function(){$("#plussetup").css("display","none")},3000);
    });

    if(ncc_warning_save){
        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){
                if(img_cut != 'TW-18UP.gif'|| token[1] == 1){
                    setTimeout(function () {$("#adult").click();},500);
                }
                clearInterval(window.ncc);
            }
        },1000);
    }

    //自動點此跳過廣告
    $("#ad_skip").change(function() {
        GM_setValue('ad_skip',$(this).prop("checked"));
        $("#plussetup").css("display","block");
        setTimeout(function(){$("#plussetup").css("display","none")},3000);
    });


    if(ad_skip_save){
        $("#ad_skip").prop("checked",true);
        window.ad_skip_checker = setInterval(function(){
            var aniad = ($(".nativeAD-skip-button,.vast-skip-button").length == 1)?$(".nativeAD-skip-button,.vast-skip-button")[0].innerText:null
            if($("video").length && $(".R18").length == 0 && $(".nativeAD-skip-button,.vast-skip-button,#an_skip_button").length == 0) {
                clearInterval(window.ad_skip_checker);
            }else if($("video").length && aniad == "點此跳過廣告"){
                $("#adSkipButton , .nativeAD-skip-button").click();
                clearInterval(window.ad_skip_checker);
            }
        },1000);
    }

    /*
//倒數5秒可點此跳過廣告
var ad_skip_countdown = 5;
if(ad_skip_save){
    $("#ad_skip").prop("checked",true);
    window.ad_skip_checker = setInterval(function(){
        if((ad_skip_countdown > 0 && $("#adSkipButton").length == 1 && $("#adSkipButton").hasClass("enabled") == false) || (ad_skip_countdown > 0 && $(".nativeAD-skip-button").length == 1 && $(".nativeAD-skip-button").hasClass("enable") == false)){
            ad_skip_countdown -= 1;
        }else if(ad_skip_countdown <= 0){
           if($("#adSkipButton").length == 1){
               $("#adSkipButton").addClass("enabled");
               $(".vast-skip-button-text").text('點此跳過廣告');
           }else if($(".nativeAD-skip-button").length == 1){
               $(".nativeAD-skip-button").addClass("enable");
               $(".nativeAD-skip-button p:first").text('點此跳過廣告');
           }
        }else if($(".R18").length == 0){
            clearInterval(window.ad_skip_checker);
        }
        console.log(ad_skip_countdown);
    },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)
    }


    //子母畫面
    window.picture = setInterval(function () {
        let picture = '<button id="plus_picture_in_picture" class="plus_picture_in_picture_icon vjs-control vjs-button vjs-show-tip" type="button" aria-disabled="false" title="子母畫面"';
        picture += '"><span aria-hidden="true" class="vjs-icon-placeholder"></span><span class="vjs-control-text" aria-live="polite"></span></button>';
        if($(".control-bar-rightbtn").length == 1 && $("#plus_picture_in_picture").length == 0){
            $(".plus_Web_fullscreen_icon").after(picture);
        }else if($("#plus_picture_in_picture").length == 1){
            clearInterval(window.picture);
            addpicture_in_picture();
        }
    },500);

    function addpicture_in_picture(){
        let video = $("#ani_video_html5_api")[0];
        $("#plus_picture_in_picture").click(function(){
            var BrowserSearch = BrowserCheck("Chrome");
            if(BrowserSearch[0] != null && BrowserSearch[1] > 70){
                if (video !== document.pictureInPictureElement){
                    video.requestPictureInPicture();
                }else{
                    document.exitPictureInPicture();
                }
            }else{
                $(".video-js").append('<div id="nopicture" class="vjs-switchRes-button">子母畫面API目前不支援Firefox及少數瀏覽器</div>');
                setTimeout(function () { $("#nopicture").remove() }, 3000);
            }
        });

        video.addEventListener('enterpictureinpicture', () => {
            $("#ani_video_html5_api").attr("poster",picture_screenshot(video,"image/jpeg",0.1));
        });
        video.addEventListener('leavepictureinpicture', () => {
            $("#ani_video_html5_api").attr("poster","");
        });
    }


    function picture_screenshot(video,imagetype,level = null){
        let canvas = document.createElement("canvas");
        canvas.width = 1920;
        canvas.height = 1080;
        let ctx = canvas.getContext("2d");
        ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
        let dataUrl = canvas.toDataURL(imagetype,level);

        return dataUrl;
    }


    //彈幕開關快捷鍵
    $('#danmu_key').val(GM_getValue("danmu_keyname"));

    $('#danmu_key').keydown(function (event) {
        event.preventDefault();
        var index = [27,32,37,38,39,40,70,77,84]
        if($.inArray(event.which,index) != -1) return;
        $(this).val(event.key);
        $(this).attr("data-key",event.which);
    });

    $("#danmu_key").focus(function(){
        $("#danmu_key_sendout").attr("disabled",false);
    });

    $("#danmu_key_sendout").click(function(){
        var keyname = $('#danmu_key').val();
        var keyid = $('#danmu_key').attr("data-key");
        GM_setValue('danmu_keyname',keyname);
        GM_setValue('danmu_keyid',keyid);
        $(this).attr("disabled",true);
    });

    $(document).keydown(function(event){
        if(event.which == GM_getValue("danmu_keyid")){
            $("#danmuToggle").click();
        }
    });


    function BrowserCheck(name){
        let Regex = name+"/(\\d*)";
        let re = new RegExp(Regex,"gm");
        let Browser = window.navigator.userAgent.match(re);
        let Search = (Browser!= null)?Browser[0].indexOf(name):null;
        let BrowserVar = (Browser!= null)?Browser[0].match(/\d*$/gm):[0];

        return [Search,BrowserVar[0]];
    }




    //在影片上右鍵選取彈幕
    function video_danmun(){
        $("video").on("mousedown", function(e) {
            e.preventDefault();
            if($(".v_danmu_box").length > 0 && !$(".v_danmu_box").is(e.target) && $(".v_danmu_box").has(e.target).length === 0 ){
                $(".v_danmu_box").remove();
            }else{
                var a = $(".cmt");
                var html = "";
                for(var i =0;i <= a.length-1;i ++) {
                    var X = (parseInt(e.offsetX) >= parseInt(a[i].offsetLeft) && parseInt(e.offsetX) <= parseInt(a[i].offsetLeft + a[i].offsetWidth));
                    var Y = (parseInt(e.offsetY) >= parseInt(a[i].offsetTop) && parseInt(e.offsetY) <= parseInt(a[i].offsetTop + a[i].offsetHeight))
                    if(X && Y && e.button===2){
                        var c = (e.offsetX > $("video").width() - 295) ? "right: 0;" : "left:" + (e.offsetX + 5) + "px;";
                        html = `<div id="video_danmu" style="top:${(e.offsetY + 5)}px; ${c}" class="v_danmu_box">
                            <input type="text" id="newkeyword" class="v_danmu_text" value="${a[i].innerText}" disabled ></input>
                            <div class="v_danmu_menu" onclick="animefun.addkeyword(); $(\'.v_danmu_box\').remove();" >過濾</div>
                            <div class="v_danmu_menu" onclick="$(\'#danmutxt\').val(\'${a[i].innerText}'); $(\'.v_danmu_box\').remove();" >複製</div>
                            </div>`;
                    }
                }
                if($(".v_danmu_box").length < 1 )$(".video-js").append(html);
            }
        });
    };



    //用戶狀態
    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;
    }

    function blockalert(v){
        unsafeWindow.alert = function (t) {
            if (!t.includes(v)){
                alert(t);
            }
        };
    }


})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址