您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Blocks Google Music Ads by muting them.
// ==UserScript== // @name Mute Google Music Ads // @namespace WillNiels // @version 1.0 // @author William Nielsen // @description Blocks Google Music Ads by muting them. // @match http*://play.google.com/music/listen* // @grant none // ==/UserScript== /* jshint -W097 */ 'use strict'; var timerTry = 1000; function muteAds(){ var volumeSlider = document.querySelector('#material-vslider'); if(localStorage.getItem("volume") == null){ localStorage.setItem("volume", 25); } if( document.querySelector('#currently-playing-title').innerHTML == "We'll be right back" ){ console.log('Mute Google Ads: Blocking the ad!'); volumeSlider.value = 0; }else{ var preValue = localStorage.getItem("volume"); console.log("Volume set to: " + preValue + "%"); volumeSlider.value = preValue; } } function setupObservers( ){ console.log("Mute Google Ads: Setting up observer."); var songInfo = document.querySelector('#playerSongInfo'); var volumeSlider = document.querySelector('#material-vslider'); if (songInfo !== null && volumeSlider !== null) { var config = { childList: true, subtree: true, attributes: true, characterData: true }; //first observer for detecting ads var observer = new window.MutationObserver(muteAds); observer.observe(songInfo, config); //second observer for saving volume setting var observer2 = new window.MutationObserver(function(){ if(volumeSlider.value !== 0) localStorage.setItem("volume",volumeSlider.value); }); observer2.observe(volumeSlider, config); } else { console.warn('Mute Google Ads: Failed to find player, Retrying...'); timerTry += 1000; setTimeout(setupObservers, timerTry); } } setTimeout(setupObservers, timerTry);