Skip to content

Instantly share code, notes, and snippets.

@Ruzzz
Last active January 4, 2016 15:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ruzzz/8643840 to your computer and use it in GitHub Desktop.
Save Ruzzz/8643840 to your computer and use it in GitHub Desktop.
Sort Ru-Board mail list
// ==UserScript==
// @name Sort Ru-Board mail list
// @author Ruzzz | ruzzzua@gmail.com
// @include http://forum.ru-board.com/tools.cgi?action=maillist
// @version 0.0.1
// @date 2014-02-04
// ==/UserScript==
(function () {
var f = document.getElementsByName("mlist")[0];
var t = f.getElementsByTagName("table")[0];
var tb = t.tBodies[0];
var th = document.createElement("thead");
th.appendChild(tb.rows[0]);
t.appendChild(th);
var tf = document.createElement("tfoot");
tf.appendChild(tb.rows[tb.rows.length-2]);
tf.appendChild(tb.rows[tb.rows.length-1]);
t.appendChild(tf);
function sortTable(table) {
var tb = table.tBodies[0];
var store = [];
for (var i = 0, l = tb.rows.length; i < l; i++) {
var row = tb.rows[i];
var s = row.cells[2].innerText;
store.push([s, row]);
}
store.sort();
for (var i = 0, l = store.length; i<l; i++)
tb.appendChild(store[i][1]);
store = null;
}
sortTable(t);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment