// ==UserScript== // @license MIT // @author Feny // @version 1.0.1 // @run-at document-body // @name M站_哔咪动漫脚本 // @icon http://www.bimiacg11.net/favicon.ico // @description 移除推广广告、播放窗口自动网页全屏、快捷键播放下一话 // @namespace http://tampermonkey.net/ // @match *://www.bimiacg4.net/* // @match *://www.bimiacg5.net/* // @match *://www.bimiacg11.net/* // @match *://www.bimiacg12.net/* // @match *://*.bimiacg*.net/bangumi/*/play/* // @require https://unpkg.com/layui@2.9.20/dist/layui.js // @require https://unpkg.com/js-cookie@3.0.5/dist/js.cookie.min.js // @downloadURL none // ==/UserScript== (function () { "use strict"; if (location.pathname === "/") { $(".login-box").remove() $(".banner-box").parents(".newhd").remove() $(".nav-area").css("margin-bottom", "20px") return } const bimiacg = { video: null, // 获取播放器容器 getVideo: function () { if (this.video) { return this.video; } this.video = $("iframe").contents().find("video").get(0); return this.video; }, // 播放 play: function (interval) { const video = this.video, isReload = Cookies.get('isReload') if (!video.paused) return clearInterval(interval); if (isReload && video.paused && video.duration > 0) { video.play().catch(() => { video.muted = true; video.play() Cookies.remove("isReload"); layer.alert("由于浏览器限制,需交互开启声音!!!", function (index) { video.muted = false; layer.close(index); }); }); } }, autoPlay: function () { let i = 0 const interval = setInterval(() => { if (this.getVideo()) this.play(interval); }, 1500); }, keydownListener: function () { function keydown(event) { if (event.key === "[") parent.document.querySelector(".play-qqun > .pre").click(); if (event.key === "]") parent.document.querySelector(".play-qqun > .next").click(); } $(document).on("keydown", keydown); $('#playleft iframe').on("load", function () { $(this.contentDocument).on("keydown", keydown) }) }, html5Settings: function () { localStorage.setItem( "html5Settings", JSON.stringify({ scale: 1, speed: 1, volume: 1, opacity: 1, density: 0, playSpeed: 1, useCSS: false, autoPlay: true, defaultFull: true, defaultWide: true, theme: "bilibili", autoOpacity: false, commentVisible: false, recordPlaySpeed: false, }) ); }, init: function () { // 移除推广 $("#bkcl").hide(); $(".tuiguang").hide(); // 视频网页全屏 $(".play-full").click(); this.autoPlay(); this.html5Settings(); this.keydownListener(); // 刷新时设置缓存 $(window).on("beforeunload", function () { Cookies.set('isReload', true, { expires: 5000 }) }); }, }; document.addEventListener("DOMContentLoaded", () => bimiacg.init()) })();