Greasy Fork

Greasy Fork is available in English.

The Tidal advertising be silent

Tidal makes the subscription advertising loud and annoying, so make it bit quailet.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         The Tidal advertising be silent
// @namespace    http://tampermonkey.net/
// @version      0.1
// @license      GPLv3
// @description  Tidal makes the subscription advertising loud and annoying, so make it bit quailet.
// @author       Gedweb
// @match        https://listen.tidal.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tidal.com
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==

(function () {
    'use strict';

    let localMuted = false;

    function checkReady() {
        let playerNode = document.getElementsByTagName('video')[0];
        if (undefined === playerNode) {
            return;
        }

        let lastVolume = playerNode.volume;

        let node, containsAD = false;
        let titleRoot = document.querySelectorAll('[data-test="footer-track-title"]')[0] || document;
        let walk = document.createTreeWalker(titleRoot, NodeFilter.SHOW_TEXT, null);
        while (node = walk.nextNode()) {
            if ("Advertisement" === node.textContent) {
                containsAD = true;
            }
        }

        if (containsAD && !localMuted) {
            playerNode.volume = 0.3;
            localMuted = true;
        } else if (localMuted) {
            playerNode.volume = lastVolume;
            localMuted = false;
        }
    }

    setInterval(function () {
        checkReady();
    }, 1000);

})();