MyShows: sort serials

Sort serials in alphabetic order on myshows.ru

当前为 2014-07-04 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        MyShows: sort serials
// @namespace   https://github.com/powerman/userjs-myshows
// @description Sort serials in alphabetic order on myshows.ru
// @include     http://myshows.ru/profile/
// @match       http://myshows.ru/profile/
// @version     2.4
// @grant       none
// ==/UserScript==

window.addEventListener('load', function(){
	'use strict';

	function restore_hover(){
		// this was copied from $(document).ready() handler in
		// http://myshows.ru/shared/minify.php?2&files=/shared/js/fe/locale/ru.js,/shared/js/fe/jquery.js,/shared/js/fe/jquery.movable-label.js,/shared/js/fe/jquery.fancybox.js,/shared/js/fe/jquery.checkboxes.js,/shared/js/fe/script.js,/shared/js/fe/md5.js,/shared/js/fe/script.custom.js,/shared/js/ext/swfobject/swfobject.js,/shared/js/fe/utils/cookie.js,/shared/js/fe/myshows.js,/shared/js/fe/social.js
		$('.status-returning a').hover (
			function () {
				showHint('', Lang.statuses.s_returning, this, $(this).parent().width()-4 , 2 );
			},
			function () {
				hideHint();
			}
		);

		$('.status-new a').hover (
			function () {
				showHint('', Lang.statuses.s_new, this, $(this).parent().width()-4 , 2 );
			},
			function () {
				hideHint();
			}
		);

		$('.status-dead a').hover (
			function () {
				showHint('', Lang.statuses.s_dead, this, $(this).parent().width()-4 , 2 );
			},
			function () {
				hideHint();
			}
		);

		$('.status-tbd a').hover (
			function () {
				showHint('', Lang.statuses.s_tbd, this, $(this).parent().width()-4 , 2 );
			},
			function () {
				hideHint();
			}
		);
	}

	function sort_shows(){
		// sort lists at left panel
		$('div.lside ul').html(function(){
			return $(this).children().sort(function(a,b){
				return $(a).text() < $(b).text() ? -1 : 1;
			});
		});
		// sort main content
		$('div.bserial').html(function(){
			return $(this).children('h4').map(function(){
				return $(this).nextUntil('h4').andSelf();
			}).sort(function(a,b){
				return a.first().text() < b.first().text() ? -1 : 1;
			}).map(function(){
				return this.get();
			});
		});
	}
	sort_shows();
	hideHint();
	restore_hover();

	$('.watch-episode').live('click', function(){
		$('#content-inner').one('DOMNodeInserted', sort_shows);
	});
}, false);