Support search owners while creating repos on Gitea/Gogs
Per
// ==UserScript==
// @name Gitea/Gogs search support
// @namespace http://tampermonkey.net/
// @version 0.1.2
// @description Support search owners while creating repos on Gitea/Gogs
// @author Scruel Tao
// @match http*://*/repo/create
// @match http*://*/repo/migrate*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const ownerMenuElement = document.querySelector('div.ui.selection.owner.dropdown div.menu');
const itemElements = Array.from(ownerMenuElement.querySelectorAll('div.item'));
const inputElement = document.createElement('input');
inputElement.setAttribute("type", "search");
inputElement.setAttribute("placeholder", "Search");
inputElement.setAttribute("aria-label", "Search");
inputElement.style.setProperty("width", "100%", "important");
ownerMenuElement.prepend(inputElement);
function filterItems() {
itemElements.forEach(item => {
const itemText = item.innerText.trim().toLowerCase();
if (itemText.indexOf(inputElement.value) == -1) {
item.style.setProperty("display", "none", "important");
return;
}
item.style.removeProperty("display");
});
}
inputElement.addEventListener('input', filterItems);
})();