MyAnimeList(MAL) - Com-to-Com Links

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

目前為 2016-08-17 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name MyAnimeList(MAL) - Com-to-Com Links
  3. // @version 1.1.3
  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].innerHTML.indexOf("All Comments") > -1) {
  20. comtocom(element[i].href);
  21. break;
  22. }
  23. }
  24. } else
  25. comtocom(document.location.href);
  26.  
  27. function comtocom(url) {
  28. if (typeof jQuery == 'undefined') $ = unsafeWindow.$;
  29.  
  30. url = url.replace(/&*show=\d*/g, "");
  31. var i = url.indexOf('id=');
  32. if (i == -1) return;
  33. url = '/comtocom.php?id1=' + url.substr(i + 3) + '&id2=';
  34.  
  35. if (document.location.href.indexOf('profile') == -1) {
  36. $('div[id^=comBox] > table > tbody > tr').each(function () {
  37. var avatar = $('.picSurround img', this);
  38. if (!avatar.length) return;
  39.  
  40. var com = $('div[id^=com]:not([id^=comtext])', this);
  41. if (!com.length) return;
  42. if (com.children().length == 3) return;
  43.  
  44. var id = avatar.attr('src');
  45. var i = id.indexOf('thumbs/');
  46. if (i == -1) return;
  47. id = id.substr(i + 7, id.indexOf('_') - i - 7);
  48.  
  49. com.append(
  50. $('<div style="margin-top:10px" align="right"/>').append(
  51. $('<a title="Comment-to-Comment">Conversation</a>').attr('href', url + id)));
  52. });
  53. } else {
  54. $('div[id^=comBox]').each(function () {
  55. if (this.getElementsByClassName('postActions ar mt4').length != 0)
  56. return;
  57. var avatar = $('img', this);
  58. if (!avatar.length) return;
  59. var id = avatar.attr('src');
  60. var i = id.indexOf('userimages/');
  61. if (i == -1) return;
  62. id = id.substr(i + 11, id.indexOf('.jpg') - i - 11);
  63. var div = document.createElement('div');
  64. div.className = 'postActions ar mt4 mr12';
  65. var link = document.createElement('a');
  66. link.href = url + id;
  67. link.innerHTML = "Conversation";
  68. div.appendChild(link);
  69. this.appendChild(div);
  70. });
  71. }
  72. }