// ==UserScript== // @version 1.0 // @author Feny // @license MIT // @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"; const pathname = location.pathname if (pathname === "/" && jQuery) { $(".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 (isReload && video.paused && video.duration > 0) { video.muted = true; video.play(); clearInterval(interval); Cookies.remove("isReload"); layer.alert( "由于浏览器限制,需手动确认开启声音!!!", function (index) { video.muted = false; layer.close(index); } ); console.log("哔咪哔咪自动播放成功!!!"); } }, autoPlay: function () { let i = 0, that = this, interval = setInterval(function () { ++i; if (i >= 5) { clearInterval(interval); } if (that.getVideo()) { that.play(interval); } }, 1500); }, keydownListener: function () { function keydown(event) { if (event.key === "[") window.parent.document.querySelector(".play-qqun > .pre").click(); if (event.key === "]") window.parent.document.querySelector(".play-qqun > .next").click(); } $(window).on("keydown", keydown); $('#playleft iframe').on('load', (event) => $(event.target).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: true, 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()) })();