icotile sort lists alphabetically

Sorts IcoTile lists alphabetically.

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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       icotile sort lists alphabetically
// @namespace  http://www.arthaey.com/
// @version    0.3
// @match      http://icotile.ogaoga.org/*
// @copyright  2013
//
// Backed up from http://userscripts.org/scripts/review/175007
// Last updated on 2013-08-04
// @description Sorts IcoTile lists alphabetically.
// ==/UserScript==

// Find all Twitter lists
var listRegex = /^list-/;
var lists = [];
var elements = document.getElementsByClassName("list-item");
for (var i = 0; i < elements.length; i++) {
    if (listRegex.test(elements[i].id)) {
        lists.push(elements[i]);
    }
}

// Sort lists by label
var sortedLists = lists.sort(function(a,b) {
    return a.getAttribute("label").localeCompare(b.getAttribute("label"));
});

// Reorder list elements alphabetically
for (var i = 0; i < sortedLists.length; i++) {
    var parent = sortedLists[i].parentNode;
    parent.removeChild(sortedLists[i]);
  parent.appendChild(sortedLists[i]);
}