Last active
June 13, 2019 01:04
-
-
Save viller239/c8b6447cce14ba6805bb0746ecdcd024 to your computer and use it in GitHub Desktop.
This file contains 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 Mute Twitch Ads | |
// @namespace http://twitch.tv | |
// @version 1.1 | |
// @description mute twitch ads | |
// @author Viller | |
// @match https://*.twitch.tv/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let volume; | |
setInterval(() => { | |
try { | |
const video = document.querySelector('video'); | |
if (!video) { | |
return; | |
} | |
const ad = document.querySelector('.player-ad-notice'); | |
if (!ad && volume) { | |
video.volume = volume; | |
volume = null; | |
} else if (ad && !volume) { | |
volume = video.volume; | |
video.volume = 0 | |
} | |
} catch (e) { /* whatever */ } | |
}, 150); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment