Wizebot Song Request Filter

16/05/2024 00:38:08

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        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)
});