Skip to content

Instantly share code, notes, and snippets.

@ttrefren
Created September 18, 2012 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttrefren/3741200 to your computer and use it in GitHub Desktop.
Save ttrefren/3741200 to your computer and use it in GitHub Desktop.
sort cardpool gift cards by discount amount
(function() {
// http://www.cardpool.com/buy-gift-cards
var table = $($("table.merchants_grid")[0]);
var boxes = table.find("td.merchant_cell");
boxes.sort(function(a, b) {
var val1 = parseInt($(a).find('.merchant_discount').text()),
val2 = parseInt($(b).find('.merchant_discount').text());
return val2 - val1;
});
for (var i = 0; i < boxes.length; i++) {
var tr = $(table.find("tr")[Math.floor(i / 5)]);
tr.append(boxes[i]);
}
// make out-of-stock obvious
$($("table.merchants_grid")[1]).css("opacity", 0.25);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment