A Chrome extension that gives you finer control over MyAnimeList.net scores
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* Patched MAL functions. */
  2. function patched_anime_checkScoreEnter(e, id) {
  3. if ((window.event ? window.event.keyCode : e.which) == 13)
  4. patched_anime_updateScore(id);
  5. else
  6. return true;
  7. }
  8. function patched_anime_updateScore(entry_id) {
  9. var new_score_centigrade = document.getElementById("scoretext" + entry_id).value;
  10. var new_score = Math.round(new_score_centigrade / 10.);
  11. var payload = {};
  12. $.post("/includes/ajax.inc.php?t=63", {id: entry_id, score: new_score}, function(data) {
  13. document.getElementById("scoreval" + entry_id).innerHTML = new_score_centigrade;
  14. document.getElementById("scoretext" + entry_id).value = "";
  15. document.getElementById("scorediv" + entry_id).style.display = "none";
  16. });
  17. payload[entry_id] = new_score_centigrade;
  18. chrome.storage.local.set(payload);
  19. }
  20. function patched_myinfo_addtolist(anime_id) {
  21. var nscore_centigrade = document.getElementById("myinfo_score").value;
  22. var nstatus = document.getElementById("myinfo_status").value;
  23. var nepsseen = document.getElementById("myinfo_watchedeps").value;
  24. var nscore = Math.round(nscore_centigrade / 10.);
  25. var payload = {};
  26. document.getElementById("myinfoDisplay").innerHTML = '<img src="http://cdn.myanimelist.net/images/xmlhttp-loader.gif" align="center">';
  27. $.post("/includes/ajax.inc.php?t=61", {aid:anime_id,score:nscore,status:nstatus,epsseen:nepsseen}, function(data) {
  28. document.getElementById("myinfoDisplay").innerHTML = '';
  29. document.getElementById("addtolist").innerHTML = data;
  30. });
  31. payload[anime_id] = nscore_centigrade;
  32. chrome.storage.local.set(payload);
  33. }
  34. function patched_myinfo_updateInfo(entry_id) {
  35. var nscore_centigrade = document.getElementById("myinfo_score").value;
  36. var nstatus = document.getElementById("myinfo_status").value;
  37. var nepsseen = document.getElementById("myinfo_watchedeps").value;
  38. var naid = document.getElementById("myinfo_anime_id").value;
  39. var curstats = document.getElementById("myinfo_curstatus").value;
  40. var nscore = Math.round(nscore_centigrade / 10.);
  41. var payload = {};
  42. document.getElementById("myinfoDisplay").innerHTML = '<img src="http://cdn.myanimelist.net/images/xmlhttp-loader.gif" align="center">';
  43. $.post("/includes/ajax.inc.php?t=62", {aid:naid,alistid:entry_id,score:nscore,status:nstatus,epsseen:nepsseen,astatus:curstats}, function(data) {
  44. document.getElementById("myinfoDisplay").innerHTML = data;
  45. });
  46. payload[entry_id] = nscore_centigrade;
  47. chrome.storage.local.set(payload);
  48. }
  49. /* Extension hooks. */
  50. function hook_animelist() {
  51. // chrome.storage.local.clear();
  52. chrome.storage.local.get(null, function(data) {
  53. $("span[id^='scoreval']").each(function(i, el) {
  54. var aid = el.id.split("scoreval")[1];
  55. var old_div = $("#scorediv" + aid);
  56. old_div.attr("id", "delete-me");
  57. var new_div = $('<div id="scorediv' + aid + '" style="display: none;"><input type="text" id="scoretext' + aid + '" size="2"><input type="button" value="Go"></div>');
  58. new_div.insertAfter(old_div);
  59. old_div.remove();
  60. var input = $("#scoretext" + aid);
  61. var button = input.next();
  62. input.keydown(function(tid) {
  63. return function(e) {
  64. return patched_anime_checkScoreEnter(e, tid);
  65. }
  66. }(aid));
  67. button.click(function(tid) {
  68. return function() {
  69. return patched_anime_updateScore(tid);
  70. }
  71. }(aid));
  72. if (aid in data) {
  73. $(el).text(data[aid]);
  74. }
  75. else {
  76. var cur = parseInt($(el).text());
  77. if (!isNaN(cur))
  78. $(el).text(cur * 10);
  79. }
  80. });
  81. });
  82. }
  83. function hook_anime(aid) {
  84. chrome.storage.local.get(aid, function(data) {
  85. var old_input = $("#myinfo_score");
  86. var old_add = $("input[name='myinfo_submit'][value='Add']");
  87. var old_update = $("input[name='myinfo_submit'][value='Update']");
  88. var score;
  89. if (old_add.length == 0 && aid in data) {
  90. score = data[aid];
  91. }
  92. else {
  93. var old_score = parseInt(old_input.val());
  94. if (old_score == 0)
  95. score = "";
  96. else
  97. score = old_score * 10;
  98. }
  99. old_input.attr("id", "delete-me");
  100. var new_input = $('<input type="text" id="myinfo_score" name="myinfo_score" class="inputtext" size="3" value="' + score + '"><span> / 100</span>');
  101. new_input.insertAfter(old_input);
  102. old_input.remove();
  103. if (old_add.length > 0) {
  104. var new_add = $('<input type="button" name="myinfo_submit" value="Add" class="inputButton">');
  105. new_add.insertAfter(old_add);
  106. old_add.remove();
  107. new_add.click(function(tid) {
  108. return function() {
  109. return patched_myinfo_addtolist(tid);
  110. }
  111. }(aid));
  112. } else {
  113. var new_update = $('<input type="button" name="myinfo_submit" value="Update" class="inputButton">');
  114. new_update.insertAfter(old_update);
  115. old_update.remove();
  116. new_update.click(function(tid) {
  117. return function() {
  118. return patched_myinfo_updateInfo(tid);
  119. }
  120. }(aid));
  121. }
  122. });
  123. }
  124. $(document).ready(function() {
  125. if (window.location.href.indexOf("/animelist/") != -1) {
  126. hook_animelist();
  127. } else if (window.location.href.indexOf("/anime/") != -1) {
  128. var aid = window.location.href.substr(window.location.href.indexOf("/anime/") + "/anime/".length);
  129. if (aid.indexOf("/") != -1)
  130. aid = aid.substr(0, aid.indexOf("/"));
  131. hook_anime(aid);
  132. }
  133. });