Jenkins - Better select boxes

enlarge & sort selects

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Jenkins - Better select boxes
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  enlarge & sort selects
// @author       You
// @match        https://jenkins.niji.fr/**
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    console.log('bsb - better select box for jenkins init');

    var selects = document.querySelectorAll('select.select');
    selects.forEach(function(select) {
        select.style.height = '400px';
        select.addEventListener('mouseover', function() {
            if (select.classList.contains('bsb-sorted') || select.children.length <= 1) {
                return;
            } else {
                select.classList.add('bsb-sorted');
            }
            console.log('bsb - sorting select options');
            var html = '';
            select.childElements()
                .sort(function(a,b) {
                return a.text == b.text ? 0 : a.text < b.text ? -1 : 1;
            })
                .forEach(function(el) { html += el.outerHTML;});
            select.innerHTML = html;
        });
    });

})();