動畫瘋·Plus

修改彈幕字型、分級標識自動同意、自動點擊按此跳過廣告、分級鎖定、可在全螢幕環境下發送彈幕

目前為 2018-07-05 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         動畫瘋·Plus
// @namespace    none
// @version      1.7.1
// @description  修改彈幕字型、分級標識自動同意、自動點擊按此跳過廣告、分級鎖定、可在全螢幕環境下發送彈幕
// @author       xu3u04u48
// @match        *://ani.gamer.com.tw/animeVideo.php?sn=*
// @grant        none
// @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
// ==/UserScript==

$('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;
}

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

.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';
}
</style>
`);


//實體化使用者介面
$("#ani-tab-content-2").prepend(`
<div class=\"ani-setting-section\">
<h4 class=\"ani-setting-title\">動畫瘋·Plus設定(外掛插件)</h4>
<div class="ani-setting-item ani-flex">
<div class="ani-setting-label">
<span class="ani-setting-label__mian">彈幕字型</span>
</div>
<div class="ani-setting-value ani-set-flex-right">
<div class="ani-checkbox">
<select id="font" class="ani-select">
<option value ="none">默認</option>
<option value ="Microsoft JhengHei">微軟正黑體</option>
<option value ="Microsoft Yahei">微軟雅黑體</option>
<option value ="DFKai-sb">標楷體</option>
<option value ="Simsun">Simsun</option>
<option value ="sans-serif">sans-serif</option>
<option value ="STHeitiTC-Light">STHeitiTC-Light</option>
<option value ="MS Mincho">MS Mincho</option>
<option value ="Meiryo">Meiryo</option>
<option value ="Arial">Arial</option>
</select>
</div>
</div>
</div>
<div class="ani-setting-item ani-flex">
<div class="ani-setting-label">
<span class="ani-setting-label__mian">自動同意分級標識警告</span>
</div>
<div class="ani-setting-value ani-set-flex-right">
<div class="ani-checkbox">
<label class="ani-checkbox__label">
<input id="grading" type="checkbox">
<div class="ani-checkbox__button"></div>
</label>
</div>
</div>
</div>
<div class="ani-setting-item ani-flex">
<div class="ani-setting-label">
<span class="ani-setting-label__mian">自動點擊按此跳過廣告</span>
</div>
<div class="ani-setting-value ani-set-flex-right">
<div class="ani-checkbox">
<label class="ani-checkbox__label">
<input id="advertising" type="checkbox">
<div class="ani-checkbox__button"></div>
</label>
</div>
</div>
</div>
<div class="ani-setting-item ani-flex">
<div class="ani-setting-label">
<span class="ani-setting-label__mian">影片加速</span>
</div>
<div class="ani-setting-value ani-set-flex-right">
<div class="ani-checkbox">
<label class="ani-checkbox__label">
<input id="acceleration" type="checkbox">
<div class="ani-checkbox__button"></div>
</label>
</div>
</div>
</div>
<div class="ani-setting-item ani-flex">
<div class="ani-setting-label">
<span id="plus-setting-label__mian" class="ani-setting-label__mian">分級鎖定</span>
</div>
<div id="plus-value" class="ani-setting-value ani-set-flex-right">
<div class="plus-keyword-header">
<input type="password" id="plus-password" class="plus-input ani-input--keyword" placeholder="首次使用須設定密碼">
<a id="plus-password-setup" href="#" role="button" class="plus-bluebtn" >設定</a>
</div>
</div>
<div id="plus-value2" class="ani-setting-value ani-set-flex-right" style="display:none">
<div class="plus-keyword-header">
<input type="password" id="plus-password2" class="plus-input ani-input--keyword" placeholder="輸入密碼">
<a id="plus-password-enter-setup" href="#" role="button" class="plus-bluebtn" >確定</a>
</div>
</div>
<div id="ncc-password" class="ani-setting-value ani-set-flex-right" style="display:none">
<div class="ani-checkbox">
<select id="grading-password" class="ani-select">
<option value ="none">無</option>
<option value ="6">保護級(含·以上)</option>
<option value ="12">補12級(含·以上)</option>
<option value ="15">補15級(含·以上)</option>
<option value ="18">限制級</option>
</select>
</div>
</div>
</div>
`);
$('.video').append(`
<div class="plus-frame">
<div class="plus-message">
<div class="plus-box">
<input type="password" id="plus-password3"  class="plus-input plus-input--keyword" placeholder="輸入密碼解除鎖定">
<a id="plus-password-enter" href="#" role="button" class="pluss-bluebtn" >確定</a>
</div>
</div>
</div>
`);

$('head').append(`
<style>
.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;
background: #00B4D8;
display: inline-block;
font-size: 1.3em;
}
.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;
}

</style>
`);


$('head').append(`
<style>
.cmt {
font-family: unset !important;
}
</style>
`);
$(".cmt").addClass("cmt");


$(document).on("mozfullscreenchange webkitfullscreenchange fullscreenchange", fullscreenChange);
function fullscreenChange(){
    var isFullScreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
    var fullScreen_bullet_send =  '<label><div class="plus_bullet-send_icon" id="plus_fullScreen-bullet-send" title="發送彈幕"><input type="button" style="display: none;" value="發送彈幕" onclick="$(\'#plus_bullet-send\').slideToggle(0);"></div></label>';

    if(isFullScreen){
        plus_bullet_control();
        plus_bullet_save();

        $(".vjs-res-button").after(fullScreen_bullet_send);
        $(".bullet-send").draggable({
            containment: "html",
            stop: function () {
                var top = $("#plus_bullet-send").css("top");
                var win_height = $(window).height();
                if(parseInt(top) > (win_height - 100)){
                    $("#plus_bullet-send").css("top",(win_height - 100));
                }
                var top_save = $("#plus_bullet-send").css("top");
                var left_save = $("#plus_bullet-send").css("left");
                localStorage.setItem('top_save',top_save);
                localStorage.setItem('left_save',left_save);
            }
        });

        $("input[type='button']").click(function(){
            $("#plus_bullet-control").css("display","none");
        });

    }else{
        $("#plus_bullet-send").remove();
        $("#plus_bullet-control").remove();
        $(".bullet-control").css("display","none");
        $("#plus_fullScreen-bullet-send").remove();
    }
}

function plus_bullet_control(){
    var 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>';
    var 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(){

    var top_save = localStorage.getItem('top_save');
    var left_save = localStorage.getItem('left_save');
    if(top_save == null || left_save == null ){
        $("#plus_bullet-send").css("top","538px");
        $("#plus_bullet-send").css("left","805px");
        var top_setup = "538px";
        var left_setup = "805px";
        localStorage.setItem('top_save',top_setup);
        localStorage.setItem('left_save',left_setup);
    }else{
        $("#plus_bullet-send").css("top",top_save);
        $("#plus_bullet-send").css("left",left_save);
    }
}





var ncc_warning_save = localStorage.getItem("ncc_warning");
var ad_skip_save = localStorage.getItem('ad_skip');
var acceleration_save = localStorage.getItem('acceleration');
var font_save = localStorage.getItem('font');
var password_save = localStorage.getItem('password_save');//密碼
var grading_save = localStorage.getItem('grading_save');//分級

//如果沒有先前的儲存值,設定預設值
if(ncc_warning_save == null){ncc_warning_save = localStorage.setItem('ncc_warning','false');}
if(ad_skip_save == null){ad_skip_save = localStorage.setItem('ad_skip','false');}
if(font_save == null){font_save = localStorage.setItem('font','none');}
if(grading_save == null){grading_save = localStorage.setItem('grading_save','none');}
if(acceleration_save == null){acceleration_save = localStorage.setItem('acceleration','false');}



//載入偵測是否有password_save
if(password_save != null  ){
    $("#plus-value").remove();
    $("#plus-value2").css("display",'');
}

if(grading_save == null){
    $(".plus-frame").remove();
}



var grading_selected = $('#grading-password').val(grading_save);//載入時預設分級選單的值
var grading =  $("#grading-password").find(":selected").val();//載入時取分級選單的值

if($('#grading-password').val() != "none"){  //分級選單
    var rating_img = $(".rating > img").attr("src");//取動畫標題旁邊的圖片連結
    var rating_img_cut = rating_img.substr(30);//切割圖片連結字串
    switch (grading_save) {
        case '6':
            if(rating_img_cut == "TW-ALL.gif"){
                $(".plus-frame").remove();
            }
            break;
        case '12':
            if(rating_img_cut == "TW-ALL.gif" || rating_img_cut == "TW-6TO12.gif"){
                $(".plus-frame").remove();
            }
            break;
        case '15':
            if(rating_img_cut == "TW-ALL.gif" || rating_img_cut == "TW-6TO12.gif" || rating_img_cut == "TW-12TO18.gif"){
                $(".plus-frame").remove();
            }
            break;
        case '18':
            if(rating_img_cut != "TW-18UP.gif"){
                $(".plus-frame").remove();
            }
            break;
    }
}else{
    $(".plus-frame").remove();
}

$("#grading-password").change(function(){
    grading =  $("#grading-password").find(":selected").val();//取<select> value
    localStorage.setItem('grading_save',grading);//設定目前的儲存值
});


$(".vjs-danmu").css("font-family",font_save);

$("#font").change(function(){
    $(document).on('DOMSubtreeModified',function () {
        var font = $("#font").find(":selected").val();
        $(".vjs-danmu").css("font-family",font);
        var font_selected = $("#font").find(":selected").val();
        localStorage.setItem('font',font_selected);
    });
});


$("#advertising").change(function() {
    if(this.checked) {
        localStorage.setItem('ad_skip','true');
    } else {
        localStorage.setItem('ad_skip','false');
    }
});


if(ad_skip_save == 'true'){
    $("#advertising").prop("checked",true);
    $(document).on('DOMSubtreeModified',function () {
        var r = $('.enabled').get(0);
        if(r != null){ r.click();}
    });
}



$("#grading").change(function() {
    if(this.checked) {
        localStorage.setItem('ncc_warning','true');
        if($(".choose").html() != null && $(".plus-frame").html() == null){
            $("#adult").click();
        }
    } else {
        localStorage.setItem('ncc_warning','false');
    }
});


if(ncc_warning_save == 'true'){
    $("#grading").prop("checked",true);
    $(document).on('DOMSubtreeModified',function () {
        if($(".choose").html() != null && $(".plus-frame").html() == null){
            $("#adult").click();
        }
    });
}




$("#acceleration").change(function() {
    if(this.checked){
        if($("#ani_video_html5_api").get(0)!=null){$("#ani_video_html5_api").get(0).playbackRate = 10;}
        localStorage.setItem('acceleration','true');
    } else {
        if($("#ani_video_html5_api").get(0)!=null){$("#ani_video_html5_api").get(0).playbackRate = 1;}
        localStorage.setItem('acceleration','false');
    }
});


if(acceleration_save == 'true'){
    $("#acceleration").prop("checked",true);
    if($("#ani_video_html5_api").get(0)!=null){$("#ani_video_html5_api").get(0).playbackRate = 10;}
}else{
    if($("#ani_video_html5_api").get(0)!=null){$("#ani_video_html5_api").get(0).playbackRate = 1;}
}






$('#setting-danmu > a').text('設定');

//首次設定密碼
$('#plus-password-setup').on('click', function() {
    var first_time_password = $("#plus-password").val();
    var password_save = localStorage.getItem('password_save');
    if(password_save != null ){
        $("#plus-value").remove();
        $("#plus-value2").css("display",'unset');
    }else if(!first_time_password){
        alert("請輸入密碼");
    }else{
        localStorage.setItem('password_save',btoa(first_time_password));
    }
});

//輸入密碼設定
$('#plus-password-enter-setup').on('click', function() {
    var enter_password_setting = $("#plus-password2").val();
    if(!enter_password_setting){
        alert("請輸入密碼");
    }else {
        var password_save = localStorage.getItem('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 = localStorage.getItem('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(`
<img src="`+rating_img1+`">
`);