NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Mute MML Commercials // @namespace http://www.tedweatherly.com/ // @version 0.3 // @description Mutes all the annoying commercials presented from NCAA's march madness web site // @author Ted Weatherly // @match http://www.ncaa.com/march-madness-live/* // @grant none // ==/UserScript== $(function() { var _DEBUG_MODE = false; var _jqBody; var _mmlElem; var _jqAdLock; var _jqTveAdblock; var _jqCommercialCoverDiv; var _lastVolume; var _loadCheckIntervalTime = 2000; // check every 2 seconds var _adCheckIntervalTime = 2000; // check every 2 seconds var _adCheckIntervalId; var _lastHref; function _init() { _jqBody = $('body'); _jqTveAdblock = null; _lastVolume = 0.5; // default _lastHref = null; _createCoverDiv(); _checkForLoad(); } function _checkForLoad() { var bIsLoading = _isLoading(); if (_DEBUG_MODE) console.log("Mute MML: bIsLoading = " + bIsLoading); // DEBUG if (bIsLoading) { window.setTimeout(_checkForLoad, _loadCheckIntervalTime); } else { _mmlElem = $('object#MML')[0]; if (_DEBUG_MODE) console.log("Mute MML: _mmlElem = " + _mmlElem); // DEBUG _jqAdLock = $('div#ad-lock'); _checkForCommercials(); } } function _checkForCommercials() { var isCommercialShowing = _isCommercialShowing(); if (_DEBUG_MODE) console.log("Mute MML: isCommercialShowing = " + isCommercialShowing); // DEBUG var volume = _mmlElem.getVolume(); var isMuted = (volume === 0); if (_DEBUG_MODE) console.log("Mute MML: isMuted = " + isMuted); // DEBUG if (isCommercialShowing && !isMuted) { if (_DEBUG_MODE) console.log("Mute MML: Commercial showing -> Need to mute"); // DEBUG _lastVolume = volume; // save volume _mmlElem.setVolume(0); // mute _jqCommercialCoverDiv.show(); // cover _jqAdLock.hide(); // allow nav changes if (_DEBUG_MODE) console.log("Mute MML: Muted"); // DEBUG } else if (!isCommercialShowing && isMuted) { if (_DEBUG_MODE) console.log("Mute MML: Commercial not showing -> Need to unmute"); // DEBUG _mmlElem.setVolume(_lastVolume); // restore volume _jqCommercialCoverDiv.hide(); // un-cover if (_DEBUG_MODE) console.log("Mute MML: Unmuted"); // DEBUG } // Also hide ads if (window.location.href != _lastHref) { // look for href changes if (_DEBUG_MODE) console.log("Mute MML: Href changed, hiding ads"); // DEBUG if (window.location.href.indexOf("/march-madness-live/game/") > 0) { _hideGamePageAds(); } else { _hideGameListAds(); } _lastHref = window.location.href; } _adCheckIntervalId = window.setTimeout(_checkForCommercials, _adCheckIntervalTime); } function _hideGamePageAds() { $('div#game-center-companions').hide(); } function _hideGameListAds() { $('div#ad-skyscraper').hide(); $('div#ad-marketing').hide(); } function _isLoading() { return _jqBody.hasClass("mml-loading"); } function _isCommercialShowing() { if (_jqTveAdblock === null) _jqTveAdblock = $('#tve-adblock'); return _jqTveAdblock.is(':visible'); } function _createCoverDiv() { var coverDivId = "videoAdCover"; var coverDivHTML = '<div id="'+coverDivId+'"></div>'; _jqBody.append(coverDivHTML); _jqCommercialCoverDiv = _jqBody.find('#'+coverDivId); _jqCommercialCoverDiv.css({"background-color": "#eee", "position": "absolute", "left": "171px", "top": "148px"}).width("766px").height("430px").hide(); } _init(); });