Звук уведомлений как ВК

lolzteam

// ==UserScript==
// @name         Звук уведомлений как ВК
// @namespace    https://lolz.live/
// @version      1
// @description  lolzteam
// @author       lolzteam
// @match        https://lolz.live/*
// @match        https://zelenka.guru/*
// @match        https://lolz.guru/*
// @icon         https://lolz.live/favicon.ico
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Ссылка на звук
    const soundUrl = 'https://www.dropbox.com/scl/fi/2bf1hf6hxlf4sc4a1gafq/zvuk-soobscheniya-vkontakte-30452.wav?rlkey=yxc1ztbp5n85343fda08u9dm2&st=7tje03ei&dl=1'; // Вставь сюда ссылку на желаемый звук, лучше залить звук на dropbox
    const audio = new Audio(soundUrl);


    audio.load();


    let lastNotificationCount = 0;

    function checkForNewNotifications() {

        const notificationElement = document.querySelector('#AlertsMenu_Counter .Total');
        const notificationContainer = document.querySelector('.navTab.alerts');

        if (notificationElement) {
            const currentNotificationCount = parseInt(notificationElement.textContent.trim(), 10) || 0;


            if (currentNotificationCount > lastNotificationCount && !notificationContainer.classList.contains('Zero')) {
                console.log('Новое уведомление обнаружено, воспроизвожу звук');
                audio.play().catch((error) => {
                    console.error('Ошибка воспроизведения звука:', error);
                });
            }


            lastNotificationCount = currentNotificationCount;
        } else {
            console.warn('Элемент с уведомлениями не найден.');
        }
    }

    setInterval(checkForNewNotifications, 5000);
})();

QingJ © 2025

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