// ==UserScript== // @license MIT // @author Feny // @version 1.0.2 // @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 *://www.bimiacg14.net/* // @match *://*.bimiacg*.net/bangumi/*/play/* // @require https://unpkg.com/layui@2.9.20/dist/layui.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() { if (this.video) { return this.video; } this.video = $("iframe").contents().find("video").get(0); return this.video; }, // 播放 play(interval) { const video = this.video if (!video.paused) return; // 偶尔刷新页面,视频不自动播放 if (video.paused && video.duration > 0) { video.play().catch(() => { video.muted = true; video.play() layer.alert("点击确认开启声音!!!", () => { video.muted = false; layer.closeAll(); }); }); } }, autoPlay() { let i = 0 const interval = setInterval(() => { if (++i >= 3) clearInterval(interval); if (this.getVideo()) this.play(); }, 500); return this }, hotkey() { function handle(event) { if (event.key === "[") parent.document.querySelector(".play-qqun > .pre").click(); if (event.key === "]") parent.document.querySelector(".play-qqun > .next").click(); } $(document).on("keydown", handle); $('#playleft iframe').on("load", function () { $(this.contentDocument).on("keydown", handle) }) return this }, storage() { 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, }) ); return this }, fullScreen() { let i = 0 const interval = setInterval(() => { const ele = $("#bkcl") if (++i >= 3) clearInterval(interval); if (ele.length > 0) { // 播放器二维码遮罩 $("#bkcl").remove(); // 视频网页全屏 $(".play-full").click(); // 移除推广 $(".tuiguang").remove(); } }, 500); return this }, init: function () { this.fullScreen().storage().autoPlay().hotkey(); }, }; document.addEventListener("DOMContentLoaded", () => bimiacg.init()) })();