LoginSignup
4
4

More than 5 years have passed since last update.

Twitter自動フォローツール

Last updated at Posted at 2019-01-09

Twitter自動フォローツールを作成しました

特定分野のユーザをたくさんフォローしたかったのですが、一日のフォロー制限はフォロワーの3倍といわれているため、フォロワーの少ない僕は凍結を恐れました。なのでフォロワーを増やす必要がありました(フォロワー3倍説はうわさです)

まずはTwitter名に"相互"と記載されているユーザを片っ端からフォローしてやろうと思ったのですが、手動だと疲れるためスクリプトを書きました

起動条件としてはPC限定でスマホでは使用できません

またとりあえず動かすことを優先したためバグだらけです。誰か直してください

以下、手順です

  1. 以下のautofollow.jsをブックマークに保存する
  2. Twitter検索欄で"相互フォロー"と検索する
  3. "相互フォロー"と名前のついたユーザのフォロワーページにいく
  4. ブックマークをクリック
  5. アラートが表示されたら、閉じて再度ブックマークをクリック(何度かやらないとフォローできません)

詳しくはブックマークレットでググってください

3のフォロワーページはココです
スクリーンショット 2019-01-09 23.38.47.png

以下、スクリプトです

autofollow.js
javascript: (function() {
    var $accountElem = $('.ProfileCard-content');
    var $username = $('.ProfileCard-content .fullname');
    var accountElemCount = $accountElem.length;
    var index = 0;
    var followCount = 0;
    var protectedCount = 0;
    var followedCount = 0;

    var manager = function() {
        if (index < accountElemCount) {
            if (notFollowing($accountElem.eq(index))
                    && protectedCheck($accountElem.eq(index))
                    && followCount < 300
                    && $username.eq(index).text().indexOf('相互') != -1) {
                performer($accountElem.eq(index));
            } else {
                index++;
                manager();
            }
        } else {
            alert('フォロー処理が完了しました。\n■実行結果\n-----------------------------------------\n表示件数:'
                    + index
                    + '\n新規フォロー:'
                    + followCount
                    + '\n鍵(フォローしない):'
                    + protectedCount
                    + '\nフォロー済み:'
                    + followedCount
                    + '\n-----------------------------------------\n');
        }
    };
    var performer = function($elem) {
        var rand = (Math.floor(Math.random() * 2000)) + 100;
        setTimeout(function() {

            $('.UserActions .not-following button.follow-text', $elem).trigger(
                    'click');

            followCount++;
            index++;
            manager();
        }, rand);
    };
    var protectedCheck = function($elem) {

        if (!$('.UserBadges .Icon--protected', $elem).length) {
            return true;
        }
        protectedCount++;

        return false;
    };
    var notFollowing = function($elem) {

        if ($('.UserActions .not-following', $elem).length) {
            return true;
        }
        followedCount++;

        return false;
    };
    id = setInterval(function(s){scrollBy(0,s||100)},1);
    setTimeout(function(){
        clearInterval(id);
        manager();
    },10000);
})();

とにかくやりたいことは"相互"と名前のついたユーザを指定ユーザの数だけフォローすることです

スクロール型の仕様は詳しくないのですが、↓スクロールすると内部的には↑に流れていくTLは消え↓から出現するTLのソースが生成されると聞いたことがあります

setTimeoutやsetIntervalで適当な時間を定めていますが、スクロール幅とフォローのタイミングがポイントのはずです

あとは任せました!

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4