您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Mute/unmute based on ad presence.
// ==UserScript== // @name Admute // @namespace Violentmonkey Scripts // @match *://open.*/* // @grant none // @version 1.0 // @author d155 // @description Mute/unmute based on ad presence. // @license GNU GPLv3 // ==/UserScript== (function() { 'use strict'; let muted = 0, adMode = 0; const finder = setInterval(() => { const muteButton = document.querySelector('[data-testid="volume-bar-toggle-mute-button"]'); const footer = document.querySelector('footer'); if (!muteButton || !footer) return; muteButton.addEventListener('click', () => { muted = muteButton.getAttribute('aria-label') === 'Mute' ? 1 : 0; }); clearInterval(finder); setInterval(() => { const ad = ( footer.querySelector('[data-testid="context-item-info-ad-title"]') || footer.querySelector('[data-testid="context-item-info-ad-subtitles"]') || footer.querySelector('[data-testid="context-item-info-ad-subtitle"]') ); if (Boolean(ad) !== adMode) { adMode = Boolean(ad); if (muted !== adMode) { muteButton.click(); muted = adMode; } } }, 500); }, 500); })();