Sort WordPress favorites alphabetically.
当前为
// ==UserScript==
// @name WordPress - Sort My Favorites
// @version 0.1
// @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
//
// ==/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/
/* STILL WORKING ON THIS! Uses div's and not li's and thus perplexing me. If you tweak it and get it working (before I figure it out) let me know, I will credit you. :)
var sorted = $.makeArray($('div.plugin-group .plugin-card .plugin-card-top .column-name')).sort(function(a,b){
console.log( $(a).children('h4').text().trim() );
return ( $(a).children('h4').text().trim() < $(b).children('h4').text().trim() ) ? -1 : 1;
});
$('div.plugin-group .plugin-card .plugin-card-top').html(sorted);
*/
});