Forked from matthewsimo/neonmob-collection-sort.js
Last active
December 19, 2015 23:59
-
-
Save oscarmarcelo/6038266 to your computer and use it in GitHub Desktop.
Sorts Neonmob Collections by rarity. (Bookmarklet is in the first comment)
This file contains 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
var common = [], uncommon = [], rare = [], veryRare = [], extremelyRare = [], chase = [], variant = [], itemType, itemWrap, items; | |
if(document.getElementsByClassName('collection').getElementsByClassName('item-grid')){ | |
itemWrap = $("div.collection ul.item-grid"); | |
itemType = "grid"; | |
} | |
if(document.getElementsByClassName('pod').getElementsByClassName('item-list')){ | |
itemWrap = $("div.pod ul.item-list"); | |
itemType = "list"; | |
} | |
items = itemWrap.children(); | |
items.each(function(i,e){ | |
var rarity; | |
if(itemType == "grid") { | |
if($(this).find("span.title").children("a").attr("class")) { | |
rarity = $(this).find("span.title").children("a").attr("class"); | |
} else { | |
rarity = $(this).find("div.piece").attr("class"); | |
rarity = rarity.replace("piece ", ""); | |
rarity = rarity.replace("one-quarter ", ""); | |
rarity = rarity.replace("empty ", ""); | |
} | |
} | |
if(itemType == "list") { | |
if($(this).find("div.info").children("h3").children("a").attr("class")) { | |
rarity = $(this).find("div.info").children("h3").children("a").attr("class"); | |
} | |
} | |
switch(rarity) { | |
case "common": | |
common.push(e); | |
break; | |
case "uncommon": | |
uncommon.push(e); | |
break; | |
case "rare": | |
rare.push(e); | |
break; | |
case "veryRare": | |
veryRare.push(e); | |
break; | |
case "extremelyRare": | |
extremelyRare.push(e); | |
break; | |
case "chase": | |
chase.push(e); | |
break; | |
case "variant": | |
variant.push(e); | |
break; | |
} | |
}); | |
prependEl = function(e) { | |
itemWrap.prepend(e); | |
} | |
common.forEach(function(e,i,a){ | |
prependEl(e); | |
}); | |
uncommon.forEach(function(e,i,a){ | |
prependEl(e); | |
}); | |
rare.forEach(function(e,i,a){ | |
prependEl(e); | |
}); | |
veryRare.forEach(function(e,i,a){ | |
prependEl(e); | |
}); | |
extremelyRare.forEach(function(e,i,a){ | |
prependEl(e); | |
}); | |
chase.forEach(function(e,i,a){ | |
prependEl(e); | |
}); | |
variant.forEach(function(e,i,a){ | |
prependEl(e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorts Neonmob Collections by rarity.
Bookmarklet:
javascript:(function(){var neonMobSort = document.createElement('script');neonMobSort.setAttribute('src', 'https://gist.github.com/oscarmarcelo/6038266/raw/61ae943f25d7b4ed60ef80b29e72fa4bafa63766/neonmob-collection-sort.js');document.body.appendChild(neonMobSort);})();