Skip to content

Instantly share code, notes, and snippets.

@tareq1988
Last active November 14, 2018 12:14
Show Gist options
  • Save tareq1988/9b68cb4a1232dcbdad87f00f9c21b92c to your computer and use it in GitHub Desktop.
Save tareq1988/9b68cb4a1232dcbdad87f00f9c21b92c to your computer and use it in GitHub Desktop.
Sort a plugin author's all plugin by active installation count on wp.org
(function($) {
var total = 0;
var list = [];
let plugins = $('#content-plugins ul li');
console.log('Number of Plugins: ' + plugins.length);
plugins.each(function(index, el) {
let plugin = $(el);
let name = plugin.find('h3 a').text();
let install = plugin.find('.active_installs').eq(0).text();
install = install.split(': ')[1].replace('Less than ', '');
install = parseInt( install.replace(',', '') );
list.push({
name: name,
active: install
});
total += install;
});
list.sort((a, b) => b.active - a.active);
console.log(list);
console.log('Total Installation: ' + total);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment