Last active
April 7, 2016 17:36
-
-
Save isevcik/9c7e3d05f5f11d8aab2a7cff1d246f0b to your computer and use it in GitHub Desktop.
Sort Shoes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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