Gab.ai User Info

Pop-up of user info on hover of mention or username link

当前为 2017-01-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Gab.ai User Info
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Pop-up of user info on hover of mention or username link
  6. // @author You
  7. // @match https://gab.ai/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. itvout = -1;
  12.  
  13. $(document).ready(function()
  14. {
  15. setInterval(setupLinks, 500);
  16. });
  17.  
  18. function setupLinks()
  19. {
  20. if($("a.inner-post-mention, a.post__meta__name__username").not(".hover-info").length > 0)
  21. {
  22. $("a.inner-post-mention, a.post__meta__name__username").not(".hover-info").each(function(){
  23. $(this).on("mouseleave", function(){
  24. $("#badge").remove();
  25. $("a.hover-info").removeClass("hover-info");
  26. });
  27. $(this).on("mouseenter", function(){
  28. if($("#badge").length > 0)
  29. return;
  30.  
  31. $("#badge").remove();
  32. var div = document.createElement("div");
  33. div.id = "badge";
  34. $(div).css("position", "absolute");
  35. $(div).css("left", $(this).offset().left + "px");
  36. $(div).css("top", $(this).offset().top - (150 + 10) + "px");
  37. $(div).css("width", "450px");
  38. $(div).css("height", "152px");
  39. $(div).css("padding", "0");
  40. $(div).css("background-color", "white");
  41. $(div).css("box-shadow", "2px 2px 3px rgba(0,0,0,.5)");
  42. $(div).html("Loading...");
  43. $(document.body).append(div);
  44. $.getJSON("https://gab.ai/users/" + $(this).text().substr(1), function(data){
  45. var html = "";
  46. html += "<div style='background-image:url(" + data.cover_url + "); background-size:cover;background-position:center;height:60px;padding:5px'>";
  47. html += "<img align='left' style='border-radius:40px;height:40px;width:40px;margin-right:7px;margin-left:5px;margin-top:5px;border:3px solid white' src='" + data.picture_url + "'/>";
  48. html += "<h2 style='text-shadow:1px 1px 0px black; color:#ff5d9f;'>" + data.name + "</h2>";
  49. html += "</div>";
  50. html += "<div style='font-size:12px; font-family:Arial;'>";
  51. html += " <div style='padding:6px;overflow:hidden;height:52px;'>" + data.bio + "</div>";
  52. html += " <div style='border-top:1px dotted #ccc; background-color:#F8F8F8;font-size:11px;height:16px;padding-top:2px'>";
  53. //html += "<span style='margin-right:5px'>? " + data.score + "</span>";
  54. html += " <span style='margin-left:5px; margin-right:5px'>" + data.post_count + " posts</span>";
  55. html += " <span style='margin-right:5px'>" + data.follower_count + " followers</span>";
  56. html += " <span style='margin-right:5px'>" + data.following_count + " following</span>";
  57. if(data.following && data.followed)
  58. html+= "<span>&rlarr; you follow each other</span>";
  59. else if(data.following)
  60. html+= "<span>&rarr; you follow " + data.username + "</span>";
  61. else if(data.followed)
  62. html+= "<span>&larr; " + data.username + " follows you</span>";
  63. html += " </div>";
  64. html += "</div>";
  65. $("#badge").html(html);
  66. });
  67. $(this).addClass("hover-info");
  68. });
  69. });
  70. }
  71. }