Wizebot Song Request Filter

16/05/2024 00:38:08

Stan na 15-05-2024. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Wizebot Song Request Filter
// @namespace   Violentmonkey Scripts
// @match       https://tools.wizebot.tv/song_request/*
// @grant       none
// @version     1.0
// @author      Alexandre D'hont - N3verlate
// @description 16/05/2024 00:38:08
// @license MIT
// ==/UserScript==

window.addEventListener("load", (event) => {

  let songListHtml = [];
  const header = document.getElementsByClassName('song_request_head')[0];

  function getSongList() {
     let songsElem = document.querySelectorAll('.mdtc-clnplrv-free-media');

      songsElem.forEach((elem, i) => {
        if(i % 2 !== 0){
          songListHtml.push(elem)
        }
      });
  }

  const actionsDiv = document.createElement('div');
  actionsDiv.style.float = 'right';
  actionsDiv.style.marginRight = '50px';
  actionsDiv.style.display = 'flex';
  actionsDiv.style.flexDirection = 'row-reverse';

  const input = document.createElement('input');
  input.style.float = 'right';
  input.style.marginRight = '10px';
  input.style.marginTop = '-12px';
  input.style.padding = '10px'
  input.placeholder = "Filtrer par pseudo";

  input.addEventListener('keyup', (event) => {
    songListHtml.forEach((elem, i) => {
      const pseudo = elem.textContent
      console.log(pseudo.toLowerCase())
      if(pseudo.toLowerCase().includes(event.target.value)){
        elem.parentElement.parentElement.style.display = 'block';
      } else {
        elem.parentElement.parentElement.style.display = 'none';
      }
    });
  });

  const refreshButton = document.createElement('button');
  refreshButton.innerHTML = 'Refresh';

  refreshButton.addEventListener('click', (event) => {
    getSongList();
  })

  actionsDiv.appendChild(refreshButton);
  actionsDiv.appendChild(input);


  header.appendChild(actionsDiv);

  setTimeout(() => {
      getSongList();
  }, 5000)
});