Search Bar for Booster Creator

Search Bar for the Booster Creator on steam to make it easier to find the pack you are wanting to create

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Search Bar for Booster Creator
// @namespace    https://github.com/encumber
// @version      2025-03-12
// @description  Search Bar for the Booster Creator on steam to make it easier to find the pack you are wanting to create
// @author       Nitoned
// @match        https://steamcommunity.com/tradingcards/boostercreator/
// @icon         https://community.fastly.steamstatic.com/public/images/economy/tradingcards/boostercreator_art.png
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    (function() {
    // Find the target select element
    let select = document.getElementById("booster_game_selector");
    if (!select) {
        console.warn("Select element with ID 'booster_game_selector' not found.");
        return;
    }

    // Find the reference div
    let referenceDiv = document.querySelector(".booster_game_selector");
    if (!referenceDiv) {
        console.warn("Div with class 'booster_game_selector' not found.");
        return;
    }

    // Create the search input
    let searchInput = document.createElement("input");
    searchInput.type = "text";
    searchInput.placeholder = "Search...";
    searchInput.style.width = "100%";
    searchInput.style.marginBottom = "5px";
    searchInput.style.padding = "5px";

    // Insert search bar after the div but before the select
    referenceDiv.insertAdjacentElement("afterend", searchInput);

    // Store original options
    let options = Array.from(select.options);

    // Add search functionality
    searchInput.addEventListener("input", function() {
        let searchTerm = this.value.toLowerCase();
        select.innerHTML = ""; // Clear existing options

        // Filter and re-add options that match search term
        options.forEach(option => {
            if (option.text.toLowerCase().includes(searchTerm)) {
                select.appendChild(option);
            }
        });
    });
})();

})();