WordPress - Sort My Favorites

Sort WordPress favorites alphabetically.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        WordPress - Sort My Favorites
// @version		0.2
// @author		Tim Berneman
// @copyright	Tim Berneman (c) 2015
// @namespace   wordpress_sort_my_favorites
// @description Sort WordPress favorites alphabetically.
// @include		/https?:\/\/profiles\.wordpress\.org\/(.*)#content-favorites\/?/
// @include		https://wordpress.org/plugins/browse/favorites/
// @grant       none
// @require     http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.js
// @run-at		document-end
//
// License: http://creativecommons.org/licenses/by-nc-sa/3.0/
//
// CHANGELOG:
// v0.1 ~ initial release - sort favorites on profiles.wordpress.org/username#content-favorites
// v0.2 ~ added more code - sort favorites on wordpress.org/plugins/browse/favorites/ as well
//
// ==/UserScript==

$(document).ready(function() {
	
	// For profiles.wordpress.org/username#content-favorites
	var sorted = $.makeArray($('#content-favorites .favorite-plugins ul li')).sort(function(a,b){
		return ( $(a).children('h3').text().trim() < $(b).children('h3').text().trim() ) ? -1 : 1;
	});
	$('#content-favorites .favorite-plugins ul').html(sorted);
	
	// For wordpress.org/plugins/browse/favorites
	var sorted = $.makeArray($('#the-list .plugin-card')).sort(function(a,b){
		return ( $(a).attr('class') < $(b).attr('class') ) ? -1 : 1;
	});
	$('#the-list').html(sorted);
});