Remove ads Twitch

Continue to view twitch stream when ad

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Remove ads Twitch
// @namespace   https://greasyfork.org/fr/users/11667-hoax017
// @match       https://www.twitch.tv/*
// @grant       none
// @version     1.0
// @author      Hoax017
// @license MIT
// @description Continue to view twitch stream when ad
// ==/UserScript==
let switched = false
function antiAdd() {
  const miniVideoparent = document.querySelector("div.picture-by-picture-player")
  const isOpen = !miniVideoparent.className.includes("picture-by-picture-player--collapsed")
  const mainVideo = document.querySelector("div.video-ref video")
  if (!isOpen) {
    if (switched) {
      mainVideo.muted = false
      switched = false
    }
    return;
  }
  const miniVideo = miniVideoparent.querySelector("video")
  // deplacer l'element mini video a coter de main video
  mainVideo.parentElement.appendChild(miniVideo)
  mainVideo.parentElement.appendChild(mainVideo.parentElement.querySelector("div"))
  // unmute mini video
  miniVideo.muted = mainVideo.muted
  mainVideo.muted = true
  switched = true
}
setInterval(antiAdd, 500)