Skip to content

Instantly share code, notes, and snippets.

@isevcik
Last active April 7, 2016 17:36
Show Gist options
  • Save isevcik/9c7e3d05f5f11d8aab2a7cff1d246f0b to your computer and use it in GitHub Desktop.
Save isevcik/9c7e3d05f5f11d8aab2a7cff1d246f0b to your computer and use it in GitHub Desktop.
Sort Shoes
// ==UserScript==
// @name Sort Shoes
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://www.bata.cz/*
// @grant none
// @grant GM_registerMenuCommand
// ==/UserScript==
(function() {
'use strict';
var sortShoes = function() {
var shoes = jQuery('li.catalog-list-article');
shoes.sort(function(a, b) {
var aprice = parseInt(jQuery(a).find('a.catalog-list-article-price').text().replace(' ', ''));
var bprice = parseInt(jQuery(b).find('a.catalog-list-article-price').text().replace(' ', ''));
if (aprice > bprice) return 1;
if (aprice < bprice) return -1;
return 0;
});
shoes.detach().appendTo(jQuery('ul.catalog-list-articles'));
};
GM_registerMenuCommand('Sort Shoes', function() {
sortShoes();
}, 'r');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment