Dribbble Extender

Shows who follows you on your following list

Stan na 04-08-2016. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Dribbble Extender
// @description  Shows who follows you on your following list
// @author       Kos
// @namespace    http://tampermonkey.net/
// @version      0.1
// @license      CC BY-SA 2.0
// @homepage     https://greasyfork.org/scripts/22003-dribbble-extender
// @include      https://dribbble.com/*/following
// @require	 https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    $(document).ready(function(){
        var following = [],
            followers = [],
            fetchActive = false,
            fullFetchFinished = false,
            curPage = 1;
        
        function getPage(page)
        {
            page = Math.round(page);
            fetchActive = true;
            $.ajax({
                url: 'https://'+document.location.hostname+document.location.pathname.replace('following', 'followers')+'?page='+page+'&per_page=20'
            }).done(function(data){
                
                var match = data.match(/Dribbble\.PlayerCards\.update\({"id":\d+,"users":(\[.*?\])/),
                arr = JSON.parse(match[1]);
                
                for (var i = 0; i < arr.length; i++)
                {
                    setFollowed(arr[i].id);
                }
                
                fetchActive = false;
                curPage++;
            }).fail(function(data){
                if (data.status == 404)
                {
                    fullFetchFinished = true;
                    return;
                }
                if (data.status == 403)
                {
                    alert('Request limit exceeded. Wait one minute and refresh page.');
                    return;
                }
            });
        }
        
        function setFollowed(id)
        {
            followers.push(id);
        }
        
        function setFollowedAll()
        {
            for (var i = 0; i < followers.length; i++)
            {
                var userBlock = $('.user-row-'+followers[i]);
                if (userBlock.hasClass('follows'))
                {
                    continue;
                }
                
                userBlock.addClass('follows');

                var title = userBlock.find('.hover-card-parent');
                title.html('<span title="Follows you" style="color: #2cff5a;">✓</span> '+title.html());
            }
            
        }
        
        var interval = setInterval(function(){
            if (fullFetchFinished)
            {
                clearInterval(interval);
                return;
            }
            
            if (!fetchActive)
            {
                getPage(curPage);
            }
        }, 250);
        
        setInterval(setFollowedAll, 500);
    });
})();