Remove ads Twitch

Continue to view twitch stream when ad

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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