MyShows: sort serials

Sort serials in alphabetic order on myshows.ru

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

  1. // ==UserScript==
  2. // @name MyShows: sort serials
  3. // @namespace https://github.com/powerman/userjs-myshows
  4. // @description Sort serials in alphabetic order on myshows.ru
  5. // @include http://myshows.ru/profile/
  6. // @match http://myshows.ru/profile/
  7. // @version 2.4
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. window.addEventListener('load', function(){
  12. 'use strict';
  13.  
  14. function restore_hover(){
  15. // this was copied from $(document).ready() handler in
  16. // 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
  17. $('.status-returning a').hover (
  18. function () {
  19. showHint('', Lang.statuses.s_returning, this, $(this).parent().width()-4 , 2 );
  20. },
  21. function () {
  22. hideHint();
  23. }
  24. );
  25.  
  26. $('.status-new a').hover (
  27. function () {
  28. showHint('', Lang.statuses.s_new, this, $(this).parent().width()-4 , 2 );
  29. },
  30. function () {
  31. hideHint();
  32. }
  33. );
  34.  
  35. $('.status-dead a').hover (
  36. function () {
  37. showHint('', Lang.statuses.s_dead, this, $(this).parent().width()-4 , 2 );
  38. },
  39. function () {
  40. hideHint();
  41. }
  42. );
  43.  
  44. $('.status-tbd a').hover (
  45. function () {
  46. showHint('', Lang.statuses.s_tbd, this, $(this).parent().width()-4 , 2 );
  47. },
  48. function () {
  49. hideHint();
  50. }
  51. );
  52. }
  53.  
  54. function sort_shows(){
  55. // sort lists at left panel
  56. $('div.lside ul').html(function(){
  57. return $(this).children().sort(function(a,b){
  58. return $(a).text() < $(b).text() ? -1 : 1;
  59. });
  60. });
  61. // sort main content
  62. $('div.bserial').html(function(){
  63. return $(this).children('h4').map(function(){
  64. return $(this).nextUntil('h4').andSelf();
  65. }).sort(function(a,b){
  66. return a.first().text() < b.first().text() ? -1 : 1;
  67. }).map(function(){
  68. return this.get();
  69. });
  70. });
  71. }
  72. sort_shows();
  73. hideHint();
  74. restore_hover();
  75.  
  76. $('.watch-episode').live('click', function(){
  77. $('#content-inner').one('DOMNodeInserted', sort_shows);
  78. });
  79. }, false);