Greasy Fork镜像 还支持 简体中文。

Bet365 Goal Alert Sound (Favourites only)

Play a sound when a goal goes in for favourited matches or competitions

目前為 2025-09-19 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Bet365 Goal Alert Sound (Favourites only)
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Play a sound when a goal goes in for favourited matches or competitions
// @match        https://www.bet365.com/*
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const audio = new Audio("https://actions.google.com/sounds/v1/cartoon/wood_plank_flicks.ogg");

    function handleGoal(node) {
        // Find the fixture container for this goal
        const fixture = node.closest(".ovm-Fixture");
        if (!fixture) return;

        // Check if this fixture or its parent competition is favourited
        const isFavourited =
            fixture.classList.contains("ovm-FavouritesContainer_Favourite") ||
            fixture.closest(".ovm-Competition")?.classList.contains("ovm-FavouritesContainer_Favourite");

        if (!isFavourited) {
            console.log("Goal detected, but not in favourites.");
            return;
        }

        // Get both team names for logging
        const teamNames = [...fixture.querySelectorAll(".ovm-FixtureDetailsTwoWay_TeamName")]
            .map(el => el.textContent.trim());

        console.log("GOAL in favourited match:", teamNames);
        audio.play().catch(err => console.warn("Audio play failed:", err));
    }

    const observer = new MutationObserver(mutations => {
        for (const mutation of mutations) {
            for (const node of mutation.addedNodes) {
                if (!(node instanceof HTMLElement)) continue;
                if (node.classList.contains("ovm-GoalEventAlert")) {
                    handleGoal(node);
                }
            }
        }
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址