Admute

Mute/unmute based on ad presence.

  1. // ==UserScript==
  2. // @name Admute
  3. // @namespace Violentmonkey Scripts
  4. // @match *://open.*/*
  5. // @grant none
  6. // @version 1.0
  7. // @author d155
  8. // @description Mute/unmute based on ad presence.
  9. // @license GNU GPLv3
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. let muted = 0, adMode = 0;
  15. const finder = setInterval(() => {
  16. const muteButton = document.querySelector('[data-testid="volume-bar-toggle-mute-button"]');
  17. const footer = document.querySelector('footer');
  18. if (!muteButton || !footer) return;
  19. muteButton.addEventListener('click', () => {
  20. muted = muteButton.getAttribute('aria-label') === 'Mute' ? 1 : 0;
  21. });
  22. clearInterval(finder);
  23. setInterval(() => {
  24. const ad = (
  25. footer.querySelector('[data-testid="context-item-info-ad-title"]') ||
  26. footer.querySelector('[data-testid="context-item-info-ad-subtitles"]') ||
  27. footer.querySelector('[data-testid="context-item-info-ad-subtitle"]')
  28. );
  29. if (Boolean(ad) !== adMode) {
  30. adMode = Boolean(ad);
  31. if (muted !== adMode) {
  32. muteButton.click();
  33. muted = adMode;
  34. }
  35. }
  36. }, 500);
  37. }, 500);
  38. })();

QingJ © 2025

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