Remove ads Twitch

Continue to view twitch stream when ad

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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)