// ==UserScript== // @name 動畫瘋·Plus // @namespace https://home.gamer.com.tw/homeindex.php?owner=xu3u04u48 // @version 2.0.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 // @downloadURL none // ==/UserScript== var update_info = { version : GM_info.script.version, content(){ return ` ${this.version} 更新
  1. 更新程式架構。
  2. 其他小修改。
`} }, funvalue = { ncc_warning : false, video_next : true, ad_skip : true, hotkey_danmu:'d_68', }, Anivalue = { pass: false, regex: /sn=(\d*)/m, str:location.search, videoSn(){ return this.regex.exec(this.str)[1]; } }, Aniplus = { ui(){ var aniplusui_html = '
'; aniplusui_html += ''; aniplusui_html += '
'; $('.sub_top').append(aniplusui_html); $('.ani-tab-content').append(''); $.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"); }; aniplus_ui_css(); $("#ani-tab-content").append(aniplus_ui_html()); load.set(); var Firefox = '因Firefox瀏覽器的政策【禁止自動播放聲音】,如果啟動此選項後無法正常播放影片
'; Firefox +='請在瀏覽器權限【防止網站自動播放聲音】將【ani.gamer.com.tw】加入例外網站
'; if(Tool.browser.BrowserCheck("Firefox")[0] != null )$("#firefox_w").after(Firefox); }, initial(){ let self = this; self.ad_skip(); self.danmu_hotkey(); setTimeout(function () { window.initial = window.setInterval(function () { if (Player.video_html()[0] == null) return; if ($(".R18").length == 0 && $(".vast-skip-button").length == 0 && Player.src().indexOf("fbcdn.net") == -1 && Player.readyState() != 0) { Anivalue.pass = true; self.danmuGet.load(); self.video_next.videoisended(); $("#plus-video-skip-minute").attr("disabled",false); $("#plus-video-skip-second").attr("disabled",false); $("#plus-video-skip-sendout").attr("disabled",false); clearInterval(window.initial); } }, 1e3); }, 1e3); }, ad_skip(){ if(load.storage.ad_skip){ $("#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 && aniad == null) { clearInterval(window.ad_skip_checker); }else if($("video").length && aniad == "點此跳過廣告"){ $("#adSkipButton , .nativeAD-skip-button").click(); clearInterval(window.ad_skip_checker); } },1000); } }, danmu_hotkey(){ $(document).keydown(function(event){ if(event.which == Tool.storage.get("hotkey_danmu").split("_")[1]){ var danmuToggle = $("#danmuToggle")[0] var e = videojs.getPlayer('ani_video').danmu.DanmuManager._setting.danmuProcess; e ? ($("#danmu-show").prop("checked", !1),danmuToggle.classList.add("vjs-danmu-close"),danmuToggle.title = "關閉彈幕") : ($("#danmu-show").prop("checked", !0),danmuToggle.classList.remove("vjs-danmu-close"),danmuToggle.title = "開啟彈幕"); videojs.getPlayer('ani_video').danmu.DanmuManager.setDanmuProcess(!e); } }); }, video_next:{ repeate:true, countdown:5, main(){ let self = this; window.videoend = window.setInterval(function () { var nextplayer = $('.playing').next().html(); var match = (nextplayer != null) ? nextplayer.match('')[1] : null; if (Player.ended() && match != null) { $("#ani_video-next").css("display", ''); $("#video_next_countdown").text(self.countdown.toString().padStart(2, "0") + " 秒後切換至下一集"); if (self.countdown == 1){ document.location.href = "https://ani.gamer.com.tw/animeVideo.php" + match }else if (self.countdown < 1){ self.countdown = 1; $("#ani_video-next").css("display", 'none'); } self.countdown -= 1; } else { self.repeate = true; $("#ani_video-next").css("display", 'none'); clearInterval(window.videoend); } }, 1e3) }, videoisended(){ let self = this; $("#ani_video-next").html('

X

'); if(load.storage.video_next){ Player.video_html().on( 'ended', function() { self.countdown = 5; let nextplayer = $('.playing').next().html(); let match = (nextplayer != null) ? nextplayer.match('
')[1] : null; if(match != null && self.repeate){ self.main(); self.repeate = false; } }); } $("#stop_video-next").click(function () { self.repeate = true; $("#ani_video-next").css("display", 'none'); clearInterval(window.videoend); }); } }, danmuGet:{ danmudata:null, main(){ let self = this; var keyword = $(".ani-keyword-body").children(".ani-keyword-label").children("span"); for(var i =0; i< keyword.length; i++){ if(keyword[i].outerText == ":" || keyword[i].outerText == ":"){ $(".plus_time_body").html(''); return; } } self.datalink().then(function(response) { self.danmudata = response; self.dataload(response,function(e){ $(".plus_time_body").html(''); if (e.length) { for (var arrayid in e) { let airborne = (e[arrayid].airborne) ? "" : "background:#bbbbbb;" $(".plus_no_sub").append('
  • ' + e[arrayid].time + '
  • '); VideoTime.skip(arrayid, e[arrayid]); } } else { $(".plus_time_body").html('') } }) }) }, datalink(){ return new Promise((resolve, reject) => { var settings = { "async": true, "crossDomain": true, "url": "ajax/danmuGet.php", "method": "POST", "data": {"sn": Anivalue.videoSn()} } $.ajax(settings).done(function (response) { resolve(response); }) }); }, dataload(data,callback){ var array = []; for (var key in data) { let asc = Tool.tobig5(data[key].text); let match = asc.match(/[0-9]{1,3}:[0-9]{1,3}/g); if (asc.indexOf("空降") != "-1" || asc.indexOf("座標") != "-1") { VideoTime.parse(asc, array, true); } else if (match) { VideoTime.parse(asc, array, false); } } var json = Tool.jsonsort(Tool.filter_r(array, 'time'), 'time'); callback(json); }, load() { let self = this; setTimeout(function () { self.main(); $(".plus_refresh,#bahablack,.bluebtn").click(function () { setTimeout(function () { self.main() }, 1e3) }); }, 1e3) } }, fullscreen:{ click_check:false, check(){ let isFullScreen = document.fullscreenElement; Aniplus.fullscreen.change(isFullScreen); Aniplus.fullscreen.hideshow(isFullScreen); }, change(isFullScreen){ let self = this; if (isFullScreen) { $("#plus_fullScreen-bullet-moving").css("display", ""); } else { self.click_check = false; $(".danmutext_area").draggable({cancel: ".danmutext_area"}); $(".danmutext_area").css({"background":"","max-width":"","top":"","left":""}); $("#plus_fullScreen-bullet-moving").css("display", "none"); } }, hideshow(isFullScreen){ 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", ""); $(".vjs-fullscreen-control").css("display", ""); } },5e2); }, web:{ main(){ let self = this; var web_fullscreen = ''; window.web_fullscreen = setInterval(function () { if($(".control-bar-rightbtn").length == 1 && $("#web_fullscreen").length == 0){ $(".vjs-fullscreen-control").after(web_fullscreen); }else if($("#web_fullscreen").length == 1){ clearInterval(window.web_fullscreen); self.add(); } }, 5e2); }, add(){ $("#web_fullscreen").click(function () { if ($("#Web_fullscreen_style").length == 0) { Tool.storage.set('web_fullscreen',true); $("head").after(''); $('#Web_fullscreen_style').html(` #animeTip {bottom: -40px !important;} html {overflow-y:hidden !important; overflow-x:hidden !important;} .vjs-indent-button {display: none !important;} .container-player {max-width: unset !important;} .player {height: 100% !important;width: 100% !important;padding-top: 0 !important;margin-top: 0 !important;z-index: 999 !important;position: fixed !important;} .videoframe {height: 100% !important;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;} @media (min-width: 1000px) .BH_background {margin-top: unset !important;} .top_sky{display: none !important;} .mainmenu {display: none !important;} .subtitle {display: none !important;} section:not(.player) {position: unset !important; display: none !important;} `); } else { $("#Web_fullscreen_style").remove(); } videojs.getPlayer("ani_video").danmu.DanmuManager.onResize(); }); $(document).keydown(function (e) { if (e.keyCode == 27 && $("#Web_fullscreen_style").length == 1) { $("#Web_fullscreen_style").remove(); videojs.getPlayer("ani_video").danmu.DanmuManager.onResize(); } }); } } }, picture_in_picture:{ main(){ let self = this; let picture = '
    '; ui_html += ''; ui_html += ''; ui_html += '
    '; ui_html += ''; ui_html += '
    '; ui_html += ''; ui_html += ''; return ui_html; } //使用者介面CSS function aniplus_ui_css(){ $('head').append(` `); } (function() { "use strict"; Tool.blockalert("廣告"); $.each(funvalue, function (key, value) { if(GM_getValue(key) != undefined){ funvalue[key] = GM_getValue(key); }else{ GM_setValue(key,value) } }) Aniplus.ui(); Aniplus.initial(); Aniplus.fullscreen.web.main(); Aniplus.picture_in_picture.main(); Aniplus.video_danmu_copy.main(); $(document).on("mozfullscreenchange webkitfullscreenchange fullscreenchange",Aniplus.fullscreen.check); })();