tdu_labo_grouping

配置希望状況を見やすくします

  1. // ==UserScript==
  2. // @name tdu_labo_grouping
  3. // @namespace tdu
  4. // @include /https?://www\.mlab\.im\.dendai\.ac\.jp/bthesis2015/StudentDeploy\.jsp$/
  5. // @include /https?://www\.mlab\.im\.dendai\.ac\.jp/bthesis2015/StudentDeploy\.jsp\?displayOrder=/
  6. // @description 配置希望状況を見やすくします
  7. // @version 1.4
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. $(function() {
  13. var $info = null;
  14. var curren_group = "";
  15. var num = 0;
  16. //http://www.mlab.im.dendai.ac.jp/bthesis/bachelor/rss.xml
  17. //https://www.mlab.im.dendai.ac.jp/bthesis/bachelor/rss.xml
  18. // var filename = '';
  19. // httpObj = new XMLHttpRequest();
  20. // httpObj.open('GET',filename,true);
  21. // httpObj.send(null);
  22. // httpObj.onreadystatechange = function(){
  23. // if ( (httpObj.readyState == 4) && (httpObj.status == 200) ){
  24. // console.log(httpObj.responseText);
  25. // }
  26. // }
  27.  
  28. var hopelist = [];
  29. var m = location.href.match(/displayOrder=(.)/);
  30. var mode = m[1] ? m[1] : 0;
  31. $.ajax({
  32. url: 'https://www.mlab.im.dendai.ac.jp/bthesis/bachelor/rss.xml',
  33. type: 'get',
  34. dataType: 'xml',
  35. timeout: 5000,
  36. success: function(xml, status) {
  37. if (status === 'success') {
  38. var row = 0;
  39. var data = [];
  40. var nodeName;
  41. // item の数だけ取得
  42. $(xml).find('item').each(function() {
  43. // 初期化
  44. data[row] = {};
  45. // 子要素を取得
  46. $(this).children().each(function() {
  47. // 要素名
  48. nodeName = $(this)[0].nodeName;
  49. // 初期化
  50. data[row][nodeName] = {};
  51. // 属性を取得
  52. attributes = $(this)[0].attributes;
  53. for (var i in attributes) {
  54. // 属性名 = 値
  55. data[row][nodeName][attributes[i].name] = attributes[i].value;
  56. }
  57. // コンテンツ
  58. data[row][nodeName]['text'] = $(this).text();
  59. });
  60. row++;
  61. });
  62. var regex = /\((.*)\) さんが、「(.*)研究室.*」に登録/;
  63. for (i in data) {
  64. var res = data[i].title.text.match(regex);
  65. if (hopelist[res[1]]) {
  66. hopelist[res[1]].unshift(res[2]);
  67. } else {
  68. hopelist[res[1]] = [res[2]];
  69. }
  70. }
  71. }
  72.  
  73. $trs = $('.entry_table tr');
  74. $head = $trs.splice(0, 1);
  75. $($head[0]).append('<th>闇</th>');
  76. $trs.each(function() {
  77. var name = $(this).children(':nth-child(3)').html();
  78. // 切れ目
  79. if (mode != 2 && curren_group != name) {
  80. if ($info) {
  81. $info.html(to_info_text(curren_group, num, mode));
  82. $(this).prev().children('td').css("border-bottom", "dotted 2px");
  83. }
  84. $(this).before('<tr class="labo-title"><td colspan="4"></td></tr>');
  85. $info = $(this).prev();
  86. num = 0;
  87. curren_group = name;
  88. }
  89. var uid = $(this).children(':nth-child(1)').html();
  90. $(this).append('<td class="yami">' + hopelist[uid].join('>') + '</td>');
  91. console.log(hopelist[uid]);
  92. num++;
  93. });
  94. $('.yami').css('font-size', '10px');
  95. $info.html(to_info_text(curren_group, num, mode));
  96. $(this).prev().children('td').css("border-bottom", "dotted 2px");
  97. },
  98. error: function() {
  99. $('body').prepend('<p style="color: red;">! LaboGroupingをonにするにはhttpsで接続する必要があります !</p>');
  100. }
  101. });
  102. });
  103.  
  104. function to_info_text(name, num, mode) {
  105. num_max = "竜田 山田 柿崎 森本 森谷".indexOf(name) == -1 ? 12 : 2;
  106. if (mode == 0) {
  107. var lib = {'星野': 12, '絹川': 8, '佐々木': 12, '小山': 12, '矢島': 11, '斎藤': 12, '小坂': 8, '中島': 8, '高橋': 12, '鉄谷': 12, '川澄': 4, '増田': 5, '岩井': 11, '竜田': 2, '山田': 2, '柿崎': 2, '森本': 2, '森谷': 2};
  108. return name + "研: (" + num + "/" + (num_max - lib[name]) + " [" + num_max + "])";
  109. }
  110. return name + "研: (" + num + "/" + num_max + ")";
  111. }
  112.