您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Mute/unmute based on ad presence.
// ==UserScript== // @name Admute // @namespace https://greasyfork.org/en/users/1441726-d155 // @match *://*spotify.com/* // @grant none // @version 2.0 // @author d155 // @description Mute/unmute based on ad presence. // @license GNU GPLv3 // ==/UserScript== (function () { 'use strict'; let muteButton = null; let adDetected = false; function findMuteButton() { const button = document.querySelector('[data-testid="volume-bar-toggle-mute-button"]'); if (button) { muteButton = button; } } function isAd() { return document.querySelector('[aria-label="Advertisement"]') !== null; } function update() { if (!muteButton || !document.body.contains(muteButton)) { findMuteButton(); } const adIsPlaying = isAd(); if (adIsPlaying && !adDetected) { adDetected = true; if (muteButton) muteButton.click(); } if (!adIsPlaying && adDetected) { adDetected = false; if (muteButton) muteButton.click(); } } setInterval(update, 500); })();