Traidores

Pone en el perfil del usuario una lista de traidores

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Traidores
// @namespace    http://taringa.net/rata__7
// @version      0.33
// @description  Pone en el perfil del usuario una lista de traidores
// @author       Nezumi cambiando script de Maag
// @match        *://www.taringa.net/*
// ==/UserScript==

var getSeguidos = function(id){
    console.log("Buscando seguidos...");
    var seguidos = [];
    var page = 1;
    var ok=true;
    while(ok){
      $.get('https://api.taringa.net/user/followings/view/' + id + '?trim_user=true&count=50&page='+ page, function(data){
        if(data.length > 0){
            seguidos.push.apply(seguidos, data);
            page++;
        } else {
            ok = false;
        }
      });
    }
    return seguidos;
};

var getSeguidores = function(id){
    console.log("Buscando seguidores...");
    var seguidores = [];
    var page = 1;
    var ok=true;
    while(ok){
      $.get('https://api.taringa.net/user/followers/view/' + id + '?trim_user=true&count=50&page='+ page, function(data){
        if(data.length > 0){
            seguidores.push.apply(seguidores, data);
            page++;
        } else {
            ok = false;
        }
      });
    }
    return seguidores;
};

var getDiferencia = function(){
    $.ajaxSetup({
        async: false,
        cache: false
    });
    var diferencia = [];
    $('#traidores-btn').attr("class", "btn r");
    var id = global_data.user;
    var seguidos = getSeguidos(id);
    var seguidores = getSeguidores(id);
    console.log("Calculando diferencias...");
    seguidos.forEach(function(u){
        if(seguidores.indexOf(u) == -1){
            diferencia.push(u);
        }
    });
    localStorage.setItem("traidores", diferencia);
    $('#traidores-btn').attr("class", "btn g");
    $.ajaxSetup({
        async: true,
        cache: true
    });
    addList(diferencia);
};

var addBtn = function(){
    $('.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>');
    $('#traidores-btn').click(getDiferencia);
};

var addList = function(diferencia){
    $.ajaxSetup({
        async: false
    });
    var sidebar = $('#sidebar');
    $('#diff-profile-box').remove();
    $('#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>');
    diferencia.forEach(function(u){
        $.get("https://api.taringa.net/user/view/" + u, function(data){
            $('#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>');
        });
    });
    $.ajaxSetup({
        async: true
    });
};

var nick = $('.user-name').html();
if(nick !== null){
    nick = nick.slice(1);
    if(window.location.pathname.slice(1) == nick){
        addBtn(nick);
        var diff = localStorage.getItem("traidores");
        $.ajaxSetup({
            async: false,
            cache: false
        });
        if(diff !== null && diff.length > 0){
            addList(diff.split(","));
        }
    }
}