Hitbox Room List Search

A Mod for room list filters.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Hitbox Room List Search
// @namespace    http://tampermonkey.net/
// @version      v1.00
// @description  A Mod for room list filters.
// @author       iNeonz
// @match        https://heav.io/game.html
// @match        https://hitbox.io/game.html
// @match        https://heav.io/game2.html
// @match        https://hitbox.io/game2.html
// @match        https://hitbox.io/game-beta.html
// @icon         https://www.google.com/s2/favicons?sz=64&domain=heav.io
// @grant        none
// @run-at       document-idle
// ==/UserScript==

const roomListTop = document.querySelector("#appContainer > div.roomListContainer > div.flexPaddingCenter > div.roomList");
const div = document.createElement('span');
div.classList.add("title");
div.classList.add("row");
roomListTop.appendChild(div);
div.innerHTML = `Includes<input style="background: #303030; border: 1px solid #222222; font-family: 'Bai Jamjuree'; outline: none; color: #ebebeb; padding: 4px;" class="nameField" maxlength="50">`;
div.style.right = '20px';
div.style.position = 'absolute';
div.style.top = '15.5px';
let mustInclude = '';

div.children[0].addEventListener('keyup',() => {
    if (mustInclude != div.children[0].value) {
        mustInclude = div.children[0].value;
        document.querySelector("#appContainer > div.roomListContainer > div.flexPaddingCenter > div.bottomButton.middle").click();
    }
})

new Promise((r) => {
    let setId = setInterval(() => {
        let roomList = document.querySelector("#appContainer > div.roomListContainer > div.flexPaddingCenter > div.roomList > div.scrollBox > table > tbody");
        if (roomList && roomList.children[0]) {
            console.log("found list")
            console.log(roomList);
            roomList.addEventListener("DOMNodeInserted", function(event){
                // newElem is the newly injected element
                let newElem = event.srcElement;
                if (newElem && newElem.parentNode.classList && newElem.parentNode.classList.contains("HOVERUNSELECTED")){
                    setTimeout(() => {

                   if(!newElem.parentNode.children[0].textContent.includes(mustInclude)) {
                       newElem.parentNode.remove();
                   }
                    },0)
                }
            });
            r();
            clearInterval(setId);
        }
    },10);
})