Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Last active August 29, 2015 14:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save unitycoder/b3c3b414b4ce1622bb9b to your computer and use it in GitHub Desktop.
Save unitycoder/b3c3b414b4ce1622bb9b to your computer and use it in GitHub Desktop.
UnityAssetStoreBuddy
// ==UserScript==
// @name AssetStoreBuddy
// @namespace unitycoder.com
// @include https://www.assetstore.unity3d.com/en/#!/search/*
// @version 1
// @grant none
// ==/UserScript==
// currently need to press F5 to run these
$(window).load(function(){
// TODO: use other methods to findout page finished
setTimeout(InitAssetStoreBuddy, 5000);
});
function InitAssetStoreBuddy()
{
// take previous search value
document.getElementById("searchInput").value = location.href.substring(location.href.lastIndexOf("/")+1,999);
// TODO: create sort by price button
SortByPrice();
}
function SortByPrice()
{
var div = document.querySelector('#packageList');
var divs = div.querySelectorAll('.littleblock');
var titleDiv = document.querySelector('#cattitle');
var nodesArray = [].slice.call(divs);
nodesArray.sort(function (a, b) {
var price1 = a.getElementsByClassName('price')[0].innerHTML.replace(/\D/g,'');
var price2 = b.getElementsByClassName('price')[0].innerHTML.replace(/\D/g,'');
return +price1 - +price2;
});
$('#packageList').empty().append(nodesArray);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment