Traidores

Pone en el perfil del usuario una lista de traidores

当前为 2016-12-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Traidores
  3. // @namespace http://taringa.net/rata__7
  4. // @version 0.30
  5. // @description Pone en el perfil del usuario una lista de traidores
  6. // @author Nezumi cambiando script de Maag
  7. // @match *://www.taringa.net/*
  8. // ==/UserScript==
  9.  
  10. var getSeguidos = function(id){
  11. console.log("Buscando seguidos...");
  12. var seguidos = [];
  13. var page = 1;
  14. var ok=true;
  15. while(ok){
  16. $.get('https://api.taringa.net/user/followings/view/' + id + '?trim_user=true&count=50&page='+ page, function(data){
  17. if(data.length > 0){
  18. seguidos.push.apply(seguidos, data);
  19. page++;
  20. } else {
  21. ok = false;
  22. }
  23. });
  24. }
  25. return seguidos;
  26. };
  27.  
  28. var getSeguidores = function(id){
  29. console.log("Buscando seguidores...");
  30. var seguidores = [];
  31. var page = 1;
  32. var ok=true;
  33. while(ok){
  34. $.get('https://api.taringa.net/user/followers/view/' + id + '?trim_user=true&count=50&page='+ page, function(data){
  35. if(data.length > 0){
  36. seguidores.push.apply(seguidores, data);
  37. page++;
  38. } else {
  39. ok = false;
  40. }
  41. });
  42. }
  43. return seguidores;
  44. };
  45.  
  46. var getDiferencia = function(){
  47. var diferencia = [];
  48. $('#traidores-btn').attr("class", "btn r");
  49. var id = global_data.user;
  50. var seguidos = getSeguidos(id);
  51. var seguidores = getSeguidores(id);
  52. console.log("Calculando diferencias...");
  53. seguidos.forEach(function(u){
  54. if(seguidores.indexOf(u) == -1){
  55. diferencia.push(u);
  56. }
  57. });
  58. localStorage.setItem("traidores", diferencia);
  59. $('#traiores-btn').attr("class","btn g");
  60. addList(diferencia);
  61. };
  62.  
  63. var addBtn = function(){
  64. $('.perfil-info').append('<div class="follow-buttons" style="display:inline-block"><a original-title="Calcula quienes no te siguen" id="traidores-btn" class="btn g"><div class="following-text">Traidores</div></a></div>');
  65. $('#traidores-btn').click(getDiferencia);
  66. };
  67.  
  68. var addList = function(diferencia){
  69. var sidebar = $('#sidebar');
  70. $('#sidebar').append('<div id="diff-profile-box" class="box w-siguiendo"><div class="title clearfix following-count"><h2>Traidores</h2><span class="action value">'+ diferencia.length +'</span></div><ul id="traidores-list" class="clearfix avatar-list"></ul></div>');
  71. diferencia.forEach(function(u){
  72. $.get("https://api.taringa.net/user/view/" + u, function(data){
  73. $('#traidores-list').append('<li class="hovercard" data-uid="' + data.id + '"><a href="/' + data.nick + '"><img src="' + data.avatar.small + '" alt="' + data.nick + '" title="' + data.nick + '"></a></li>');
  74. });
  75. });
  76. };
  77.  
  78. var nick = $('.user-name').html();
  79. if(nick !== null){
  80. nick = nick.slice(1);
  81. if(window.location.pathname.slice(1) == nick){
  82. addBtn(nick);
  83. var diff = localStorage.getItem("traidores");
  84. $.ajaxSetup({
  85. async: false
  86. });
  87. if(diff !== null && diff.length > 0){
  88. addList(diff.split(","));
  89. }
  90. }
  91. }