Last active
March 7, 2016 08:25
-
-
Save lamchau/dddc531bb39d0c673e0c to your computer and use it in GitHub Desktop.
wip: tamper-monkey script for package control
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
// bug https://packagecontrol.io/browse/popular | |
var parent = $("ul.packages"); | |
var toggle_st3 = $('<label><input type="checkbox" style="-webkit-appearance:checkbox !important"/> Hide ST3</label>') | |
.click(function() { | |
var checked = $(this).find("input").is(":checked"); | |
var versions = $(".versions").parent(); | |
if (checked) { | |
versions.hide(); | |
} else { | |
versions.show(); | |
} | |
}); | |
toggle_st3.insertBefore(parent); | |
function valueOf(element) { | |
var value = $(element).find(".installs").attr("title"); | |
return parseInt(String(value).replace(",", "")); | |
} | |
var sort_direction = 'none'; | |
var sorter = $('<div style="cursor:pointer">none</div>') | |
.click(function() { | |
if (sort_direction === 'none' || sort_direction === 'ascending') { | |
sort_direction = 'descending' | |
} else { | |
sort_direction = 'ascending' | |
} | |
this.innerHTML = sort_direction; | |
var packages = parent.find("li.package").sort(function(a, b) { | |
a = valueOf(a); | |
b = valueOf(b); | |
if (sort_direction === 'descending') { | |
return a > b ? -1 : 1; | |
} else { | |
return a < b ? -1 : 1; | |
} | |
}); | |
packages.detach().appendTo(parent); | |
}); | |
sorter.insertBefore(parent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment