// ==UserScript==
// @name       Twitter followers
// @include    https://twitter.com/*
// @version    0.1
// @author     sportclub2010
// @grant      none
// ==/UserScript==

if (document.location.href.indexOf('followers') != -1){
    document.body.onkeydown = function(e) {
        e = e || event;
        if (e.keyCode == 13) {
            var Grid = document.getElementsByClassName('Grid-cell u-size1of2 u-lg-size1of3 u-mb10');
            Grid = Array.from(Grid).filter(b => !b.querySelectorAll(".btn-group:not(.not-following)").length);
            var i=0;
            var btn = [];
            function Timer() {
                document.getElementsByTagName('title')[0].innerHTML = Grid.length + ' ' + i;
                btn = Grid[i].getElementsByClassName('user-actions-follow-button js-follow-btn follow-button');
                if(btn[0]){
                    if (Grid[i].innerHTML.toLowerCase().indexOf('followback') != -1) btn[0].click();
                }
                i++;
                if(i<12) setTimeout(Timer, 2000);
                //if(i<Grid.length) setTimeout(Timer, 2000);
            }
            setTimeout(Timer, 2000);
        }
    }
}