Twitter Unfollow Bookmarklet

  • /*
     * @title Twitter Unfollow Bookmarklet
     * @description twitter でfollowing を全員unfollow するブックマークレット http://d.hatena.ne.jp/laiso/20111029/p1
     * @include https://mobile.twitter.com/*
     * @license New BSD License
     * @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
     * @require https://raw.github.com/laiso/jquery.ajaxQueue/master/ajaxQueue.js
     */
    
    /*
     * https://mobile.twitter.com/ のモバイルサイトへログインして https://mobile.twitter.com/following で実行
     */
    
    (function(){
      var LIMIT = 1000000000;
    
      var screen_name = document.querySelector('.timeline-user b').innerText;
      var authenticity_token = document.querySelector('input[name=authenticity_token]').value;
      
      var queue = new ajaxQueue();
      
      var unfollow = function(id){
        var d = new $.Deferred();
        endPoint = 'https://mobile.twitter.com/'+id+'/unfollow';
        queue.add(endPoint, 'POST', {
          data: 'authenticity_token='+authenticity_token+'&_method=delete&lasturl=%2Ffollowing',
          success: d.resolve
        });
        return d.promise();
      };
    
      $.ajax({
          crossDomain: true,
          dataType: 'jsonp',
          url: 'http://api.twitter.com/1/friends/ids.json?screen_name='+screen_name+'&callback=?',
          success: function(ids){
            var d = $.when();
            $(ids).each(function(i, id){
              if(LIMIT < i) return;
              d.pipe(function(){
                unfollow(id)
                  .done(function(){
                    console.log('unfollow http://twitter.com/' + id + ' ' + i +' / ' + LIMIT);
                  })
                  .fail(function(){
                    console.log('failed unfollow http://twitter.com/' + id);
                  });
              });
            });
            queue.run();
          }
      });
    }());
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2011/10/29 20:14:55 - 2011-10-29
  2. 2011/10/29 19:58:42 - 2011-10-29
  3. 2011/10/29 19:57:28 - 2011-10-29
  4. 2011/10/29 19:51:12 - 2011-10-29
  5. 2011/10/29 15:59:25 - 2011-10-29
  6. 2011/10/29 01:05:01 - 2011-10-29
  7. 2011/10/29 00:58:58 - 2011-10-29