10bis enhancer

By Yehuda B. Last update Dec 15, 2008 — Installed 372 times. Daily Installs: 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0

There are 3 previous versions of this script.

// 10bis enhancer user script
// version 0.3
// 2008-08-05
// Copyright (c) 2008, Yehuda B.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// http://www.gnu.org/licenses/gpl.html
//
// ==UserScript==
// @name           10bis enhancer
// @description	10bis food delivery site improvements. Version 0.4
// @namespace      http://yehudab.com
// @include        http://www.10bis.co.il/*
// ==/UserScript==

function fixTable(lineType) {
    var tbl = document.getElementById(lineType + "_res_list_table");
	var rows = tbl.rows;
	var i, l = rows.length;
	var myRows = new Array();
	for (i = 0; i < l; i++)
	{
	    var html = rows[i].innerHTML;
		var nonZero =  html.match(/(סך הזמנה עד כה:[^0-9]*)([1-9][0-9]+)/);

		myRows[i] = new Object();
		if (nonZero)
		{
			myRows[i].totalSoFar = parseInt(nonZero[2], 10);
			html = html.replace(/(סך הזמנה עד כה:[^0-9]*)([0-9]+)/g, "$1<span style=\"font-size:3em\">$2</span>");
		}
		else
		{
			myRows[i].totalSoFar = 0;
		}
		myRows[i].innerHTML = html;
	}
	myRows.sort(compareTotals);
	for (i = 0; i < l; i++)
	{
		rows[i].innerHTML = myRows[i].innerHTML;
	}	
}

function compareTotals(row1, row2)
{
	return row2.totalSoFar - row1.totalSoFar;
}
if (document.getElementById("pool_res_list_table"))
{
	fixTable("pool");
	fixTable("grace");
}