-
Notifications
You must be signed in to change notification settings - Fork 1
/
alphabeticalSiteSearchAPI.user.js
33 lines (30 loc) · 1.27 KB
/
alphabeticalSiteSearchAPI.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// ==UserScript==
// @name Make API site search alphabetical
// @namespace http://stackexchange.com/users/4337810/
// @version 1.0
// @description Makes the list of sites under the site search on api.stackexchange.com alphabetical
// @author ᔕᖺᘎᕊ (http://stackexchange.com/users/4337810/)
// @match *://api.stackexchange.com/*
// @grant none
// ==/UserScript==
var userscript = function($) {
setTimeout(function() {
console.log('start');
//Thanks to http://stackoverflow.com/a/1134983/3541881 for the main sorting part of the script!
$('.site-picker.ui-autocomplete-input').on('input', function() {
console.log('change');
setTimeout(function() {
var mylist = $('body > ul.ui-autocomplete');
var listitems = mylist.children('li').get();
listitems.sort(function(a, b) {
return $(a).text().toUpperCase().localeCompare($(b).text().toUpperCase());
})
$.each(listitems, function(idx, itm) { mylist.append(itm); });
}, 500);
});
}, 1000);
};
var el = document.createElement('script');
el.type = 'text/javascript';
el.text = '(' + userscript + ')(jQuery);';
document.head.appendChild(el);