ZodGame-自动播放BGM

楼主添加的BGM之后,坛友进入帖子将自动播放

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         ZodGame-自动播放BGM
// @namespace    https://zodgame.xyz/home.php?mod=space&uid=294326
// @version      1.0
// @description  楼主添加的BGM之后,坛友进入帖子将自动播放
// @author       未知的动力
// @match        https://zodgame.xyz/forum.php?mod=viewthread&tid=*
// @run-at      document-start
// ==/UserScript==

// 比如: 
// https://zodgame.xyz/forum.php?mod=viewthread&tid=294029

class MonitorDOM {
    constructor(t, o, n = null, e = "childList") {
        this.ele = t, this.callback = o, this.config = null == n ? {
            attributes: !0,
            childList: !0,
            subtree: !0
        } : n, this.monitorType = e
    }
    startMonitor() {
        let t = this;
        let o = new MutationObserver((function (o, n) {
            for (let n of o) n.type == t.monitorType && t.callback()
        }));
        o.observe(t.ele, t.config), t._monitorHandle = o
    }
    stopMonitor() {
        this._monitorHandle.disconnect()
    }
}! function () {
    "use strict";
    const t = new MonitorDOM(document.documentElement, (function () {
        const o = document.querySelector("audio");
        o && (o.autoplay = !0, o.loop = "loop", t.stopMonitor())
    }));
    t.startMonitor()
}();