// ==UserScript==
// @name 動畫瘋·Plus
// @namespace none
// @version 1.9.2
// @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
// @downloadURL none
// ==/UserScript==
$('head').append(`
`);
//實體化使用者介面
$("#ani-tab-content-2").prepend(`
動畫瘋·Plus設定(外掛插件)
分級鎖定
`);
$('.video').append(`
`);
$('head').append(`
`);
/*
$('head').append(`
`);
$(".cmt").addClass("cmt");
*/
$(function (){
var Switch = true;
var qtimer = setInterval(function(){
if($(".R18").length == 0 && $(".plus-frame").length == 0){
$(".vjs-fullscreen-control").after('
');
clearTimeout(qtimer);
}
$("#Web_fullscreen").click(function(){
if(Switch){
Switch = false;
var win_height = $(window).height();
$("body").after('
');
$("#animeTip").css("bottom","-40px");
$("html").css("overflow-y","hidden");
$("html").css("overflow-x","hidden");
$(".videoframe").css("height",(win_height-40)+"px");
$(".videoframe").css("width","100%");
$(".videoframe").css("margin","auto");
$(".vjs-indent-button").css("display","none");
$(".plus_Web_fullscreen_icon").css("color","#fff");
$(".plus_Web_fullscreen_icon").css("background","#333");
}else{
Switch = true;
$("#Web_fullscreen_style").remove();
$("#animeTip").css("bottom","0px");
$("html").css("overflow-y","unset");
$("html").css("overflow-x","unset");
$(".videoframe").css("height","");
$(".videoframe").css("width","");
$(".videoframe").css("margin","");
$(".vjs-indent-button").css("display","unset");
$(".plus_Web_fullscreen_icon").css("color","");
$(".plus_Web_fullscreen_icon").css("background","");
}
$(window).resize(function() {
if(!Switch){
var win_height = $(window).height();
$(".videoframe").css("height",(win_height-40)+"px");
}
});
$('#Web_fullscreen_style').append(`
`);
});
},2000);
$(document).on("mozfullscreenchange webkitfullscreenchange fullscreenchange", fullscreenChange);
function fullscreenChange(){
var isFullScreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
var fullScreen_bullet_send = '
';
if(isFullScreen){
plus_bullet_control();
plus_bullet_save();
$(".vjs-danmu-button").after(fullScreen_bullet_send);
$(".plus_Web_fullscreen_icon").css("display","none");
$(".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");
$("#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(){
var bullet_send = '
'+$(".bullet-send").html()+'
';
var bullet_control = '
'+$(".bullet-control").html()+'
';
$("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','unset');}
if(grading_save == null){grading_save = localStorage.setItem('grading_save','none');}
//if(acceleration_save == null){acceleration_save = localStorage.setItem('acceleration','false');}
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();
localStorage.setItem('grading_save',grading);
});
/*$("#font").val(font_save);
$(".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');
}
});
var ANIME_BP = localStorage.getItem('ANIME_BP');
if(ANIME_BP != null ){
var ANIME_BP_JSON = JSON.parse(ANIME_BP);
var ANIME_BP_JSON_time = ANIME_BP_JSON.time;
var ANIME_BP_JSON_sn = ANIME_BP_JSON.sn;
}
if(ad_skip_save == 'true'){
$("#advertising").prop("checked",true);
var vtimer = setInterval(function(){
if($(".enabled").length > 0 && $(".plus-frame").length == 0){
$(".enabled").click();
localStorage.setItem('ANIME_BP','{"sn":"'+location.search.split("=")[1]+'","time":"0"}');
var etimer = setTimeout(function(){
if(location.search.split("=")[1] == ANIME_BP_JSON_sn && ANIME_BP_JSON.time != 0){$("#ani_video_html5_api").get(0).currentTime = ANIME_BP_JSON_time;}
//clearTimeout(etimer);
clearTimeout(vtimer);
},3000);
}
if($("#ani_video_html5_api").get(0).currentTime > 31 ){
clearTimeout(vtimer);
}
},1000);
}
$("#grading").change(function() {
if(this.checked) {
localStorage.setItem('ncc_warning','true');
if($(".choose").length > 0 && $(".plus-frame").length == 0){
$("#adult").click();
}
} else {
localStorage.setItem('ncc_warning','false');
}
});
if(ncc_warning_save == 'true'){
$("#grading").prop("checked",true);
$('head').append('');
var timer = setInterval(function(){
if($(".choose").length > 0 && $(".plus-frame").length == 0){
$("#adult").click();
clearTimeout(timer);
}
},2000);
}
$("#acceleration").change(function() {
if(this.checked){
if($("#ani_video_html5_api").get(0)!=null){$("#ani_video_html5_api").get(0).playbackRate = 10;}
$(document).on('DOMSubtreeModified',function () {
if($("#ani_video_html5_api").get(0).ended || $("#ani_video_html5_api").get(0).networkState == 3){
$("#acceleration").attr("checked",false);
}
});
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(`

`);
});