Skip to content

Instantly share code, notes, and snippets.

@viller239
Last active June 13, 2019 01:04
Show Gist options
  • Save viller239/c8b6447cce14ba6805bb0746ecdcd024 to your computer and use it in GitHub Desktop.
Save viller239/c8b6447cce14ba6805bb0746ecdcd024 to your computer and use it in GitHub Desktop.
// ==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