MyAnimeList(MAL) - Com-to-Com Links

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

目前為 2023-01-22 提交的版本,檢視 最新版本

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