A Chrome extension that gives you finer control over MyAnimeList.net scores
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

90 Zeilen
3.1 KiB

  1. function patched_anime_checkScoreEnter(e, id) {
  2. if ((window.event ? window.event.keyCode : e.which) == 13)
  3. patched_anime_updateScore(id);
  4. else
  5. return true;
  6. }
  7. function patched_anime_updateScore(entry_id) {
  8. var new_score_centigrade = document.getElementById("scoretext" + entry_id).value;
  9. var new_score = Math.round(new_score_centigrade / 10.);
  10. var payload = {};
  11. $.post("/includes/ajax.inc.php?t=63", {id: entry_id, score: new_score}, function(data) {
  12. document.getElementById("scoreval" + entry_id).innerHTML = new_score_centigrade;
  13. document.getElementById("scoretext" + entry_id).value = "";
  14. document.getElementById("scorediv" + entry_id).style.display = "none";
  15. });
  16. payload[entry_id] = new_score_centigrade;
  17. chrome.storage.local.set(payload);
  18. }
  19. function hook_animelist() {
  20. // chrome.storage.local.clear();
  21. chrome.storage.local.get(null, function(data) {
  22. $("span[id^='scoreval']").each(function(i, el) {
  23. var aid = el.id.split("scoreval")[1];
  24. var old_div = $("#scorediv" + aid);
  25. old_div.attr("id", "delete-me");
  26. var new_div = $('<div id="scorediv' + aid + '" style="display: none;"><input type="text" id="scoretext' + aid + '" size="2"><input type="button" value="Go"></div>');
  27. new_div.insertAfter(old_div);
  28. old_div.remove();
  29. var input = $("#scoretext" + aid);
  30. var button = input.next();
  31. input.keydown(function(tid) {
  32. return function(e) {
  33. return patched_anime_checkScoreEnter(e, tid);
  34. }
  35. }(aid));
  36. button.click(function(tid) {
  37. return function() {
  38. return patched_anime_updateScore(tid);
  39. }
  40. }(aid));
  41. if (aid in data) {
  42. $(el).text(data[aid]);
  43. }
  44. else {
  45. var cur = parseInt($(el).text());
  46. if (!isNaN(cur))
  47. $(el).text(cur * 10);
  48. }
  49. });
  50. });
  51. }
  52. function hook_anime(aid) {
  53. chrome.storage.local.get(aid, function(data) {
  54. var old_input = $("#myinfo_score");
  55. var score;
  56. if (aid in data) {
  57. score = data[aid];
  58. }
  59. else {
  60. var old_score = parseInt(old_input.val());
  61. if (old_score == 0)
  62. score = "";
  63. else
  64. score = old_score * 10;
  65. }
  66. old_input.attr("id", "delete-me");
  67. var new_input = $('<input type="text" id="myinfo_score" name="myinfo_score" class="inputtext" size="3" value="' + score + '"><span> / 100</span>');
  68. new_input.insertAfter(old_input);
  69. old_input.remove();
  70. });
  71. }
  72. $(document).ready(function() {
  73. if (window.location.href.indexOf("/animelist/") != -1) {
  74. hook_animelist();
  75. } else if (window.location.href.indexOf("/anime/") != -1) {
  76. var aid = window.location.href.substr(window.location.href.indexOf("/anime/") + "/anime/".length);
  77. if (aid.indexOf("/") != -1)
  78. aid = aid.substr(0, aid.indexOf("/"));
  79. hook_anime(aid);
  80. }
  81. });