Wizebot Song Request Filter

16/05/2024 00:38:08

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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