MyAnimeList(MAL) - Com-to-Com Links

Add Com-to-Com link between user and comment user for every comment.

当前为 2017-04-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MyAnimeList(MAL) - Com-to-Com Links
  3. // @version 1.1.6
  4. // @description Add Com-to-Com link between user and comment user for every comment.
  5. // @author Cpt_mathix & N_Ox
  6. // @include *://myanimelist.net/profile*
  7. // @include *://myanimelist.net/comments*
  8. // @exclude *://myanimelist.net/profile/*/reviews
  9. // @exclude *://myanimelist.net/profile/*/recommendations
  10. // @exclude *://myanimelist.net/profile/*/clubs
  11. // @exclude *://myanimelist.net/profile/*/friends
  12. // @grant none
  13. // @namespace https://greasyfork.org/users/16080
  14. // ==/UserScript==
  15.  
  16. if (document.location.href.indexOf('profile') > -1) {
  17. var element = document.getElementById('lastcomment').getElementsByTagName('a');
  18. for(var i = 0; i < element.length; i++) {
  19. if (element[i] && element[i].innerHTML.indexOf("All Comments") > -1) {
  20. comtocom(element[i].href);
  21. break;
  22. }
  23. }
  24. } else {
  25. comtocom(document.location.href);
  26. }
  27.  
  28. function comtocom(url) {
  29. if (typeof jQuery == 'undefined') $ = unsafeWindow.$;
  30.  
  31. url = url.replace(/&*show=\d*/g, "");
  32. var i = url.indexOf('id=');
  33. if (i == -1) return;
  34. url = '/comtocom.php?id1=' + url.substr(i + 3) + '&id2=';
  35.  
  36. if (document.location.href.indexOf('profile') == -1) {
  37. $('div[id^=comBox] > table > tbody > tr').each(function () {
  38. var avatar = $('.picSurround img', this);
  39. if (!avatar.length) return;
  40.  
  41. var com = $('div[id^=com]:not([id^=comtext])', this);
  42. if (!com.length) return;
  43. if (com.children().length == 3) return;
  44.  
  45. var id = avatar.attr('src') || avatar.data("src");
  46. var i = id.indexOf('thumbs/');
  47. if (i == -1) return;
  48. id = id.replace(/\D+/g,'');
  49.  
  50. com.append(
  51. $('<div style="margin-top:10px" align="right"/>').append(
  52. $('<a title="Comment-to-Comment">Conversation</a>').attr('href', url + id)));
  53. });
  54. } else {
  55. $('div[id^=comBox]').each(function () {
  56. if (this.getElementsByClassName('postActions ar mt4').length !== 0)
  57. return;
  58.  
  59. var avatar = $('img', this);
  60. if (!avatar.length) return;
  61.  
  62. var id = avatar.attr('src') || avatar.data("src");
  63. var i = id.indexOf('userimages/');
  64. if (i == -1) return;
  65. id = id.replace(/\D+/g,'');
  66.  
  67. var div = document.createElement('div');
  68. div.className = 'postActions ar mt4 mr12';
  69. var link = document.createElement('a');
  70. link.href = url + id;
  71. link.innerHTML = "Conversation";
  72.  
  73. div.appendChild(link);
  74. this.appendChild(div);
  75. });
  76. }
  77. }