Created
December 18, 2017 20:32
-
-
Save tannerkrewson/2bf2cfc3b0e5f959a32b2b5f9797f74d to your computer and use it in GitHub Desktop.
Hulu Auto Pause After Ad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Hulu Auto Pause After Ad | |
// @author Tanner Krewson | |
// @match https://www.hulu.com/* | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var time; | |
var wasAdDisplayedBefore = false; | |
var checker = setInterval(function() { | |
var adIsDisplayed = $('.ad-blocker').length; | |
if (adIsDisplayed && !wasAdDisplayedBefore) { | |
$('.ad-top-bar').hide(); | |
$('.ad-blocker-message').remove(); | |
$('.ad-blocker-button').remove(); | |
$('.time-countdown').on("DOMSubtreeModified", function() { | |
time = parseInt($('.time-countdown').text()); | |
$('.ad-blocker-title').text(time + ' seconds left'); | |
if (time <= 1) { | |
$('.play-pause-button').click(); | |
$('.ad-blocker-title').text('Unpause to continue watching'); | |
$('.time-countdown').off("DOMSubtreeModified"); | |
} | |
}); | |
} | |
wasAdDisplayedBefore = adIsDisplayed; | |
}, 50); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment