Search Bar on Palettes Panel

Adds a search bar to the palettes panel.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Search Bar on Palettes Panel
// @namespace    Vholran.SearchBarOnPalettesPanel
// @version      1.0.2
// @description  Adds a search bar to the palettes panel.
// @author       Vholran (https://greasyfork.org/en/users/841616)
// @match        https://*.drawaria.online/*
// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js
// @icon         https://www.google.com/s2/favicons?domain=drawaria.online
// @grant        none
// ==/UserScript==

(($, undefined) => {
    $(() => {
        $('#palettechooser').find('.modal-body').before(`
  <div style="display: flex; flex-wrap: wrap;">
    <input id="searchPalettes" class="form-control" placeholder="Search Palettes" style="flex-grow: 1; font-size: calc(100% + 0.15rem); margin: 0.95rem; padding: 1.3rem 1rem; width: 0;" type="text">
  </div>
`);

        $('body').on('input', '#searchPalettes', e => {
            const searchValue = e.target.value.toLowerCase();
            $('#palettechooser-list').children().hide();
            $('.palettechooser-rowname').filter((index, element) => {
                return $(element).text().toLowerCase().includes(searchValue);
            }).parent().show();
        });
        $('body').on('click', '.palettechooser-row', () => {
            if($('.selmode-palettechooser-list').length){
                $('.drawcontrols-button.drawcontrols-color.drawcontrols-arrow').click();
                $('.pcr-app').removeClass('visible');
            }
        });
    });
})(window.jQuery.noConflict(true));