LoginSignup
7
8

More than 3 years have passed since last update.

善か悪か twitterで一括フォローするブックマークレットを使いやすいように改造した

Last updated at Posted at 2017-12-19

注意

2019/05/27現在このブックマークレットは
Twitter社の対策により使えなくなっていますテヘペロ!

はじめに

JavaScript Advent Calendar 2017 - Qiitaの19日目の記事です。

小ネタですが空いてたので失礼します:bride_with_veil:

導入

みなさんはtwitter利用していますか??
twitterを利用しているときにこんな事ないですか?

  • 「この人がフォローしている人興味深い!全員フォローしよう!」←善
  • 「とりあえず無作為にフォローしまくってやろう!」←悪
  • 「twitterの関係をリセットしたい...フォロワー全員リフォローしよう...」←闇
_人人人人人人人人人人人人人人人人人人人人人人人_ > とりあえず1件1件クリックするのめんどくさい <  ̄Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y ̄

そんなことないですか?
ググったらいつものブックマークレットが出てくるので、使いやすいようにカスタマイズしてみました。
※悪用はしないように:japanese_goblin:

いつものブックマークレット

とりあえず検索して一番上に出てくる(2017/12/19現在)ものがこちら。

javascript:(function(d){function l(){(function($){$('.follow-button').trigger('click');})(jQuery)}if(typeof jQuery=='undefined'){var j=d.createElement('script');j.type='text/javascript';j.src='https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';d.body.appendChild(j);j.onload=l}else{l()}})(document);

ワンラインじゃないとこんな感じ

javascript:(
  function(d){
    function l(){(
      function($){
        $('.follow-button').trigger('click');
      }
    )(jQuery)}
    if(typeof jQuery=='undefined'){
      var j=d.createElement('script');
      j.type='text/javascript';
      j.src='https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
      d.body.appendChild(j);
      j.onload=l
    }else{
      l()
    }
  }
)(document);

参照:スマホでTwitterの一括フォローをやっちゃうよ。ブックマークレットだよ。

これを使うと一括フォローできます。

がっ!しかし!

「すでにフォローしている人はリフォローされてしまう」

という欠点を持ち合わせています。

カスタマイズしてみた

本当にちょろっと手をくわえただけです。

フォローしていない人のみフォローするブックマークレット

フォローしていないユーザーのフォローボタンにはnot-followingクラスがつきます。

javascript:(function(d){function l(){(function($){$('.not-following .follow-button').trigger('click');})(jQuery)}if(typeof jQuery=='undefined'){var j=d.createElement('script');j.type='text/javascript';j.src='https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';d.body.appendChild(j);j.onload=l}else{l()}})(document);

ワンラインじゃないとこんな感じ

javascript:(
  function(d){
    function l(){(
      function($){
        $('.not-following .follow-button').trigger('click');
      }
    )(jQuery)}
    if(typeof jQuery=='undefined'){
      var j=d.createElement('script');
      j.type='text/javascript';
      j.src='https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
      d.body.appendChild(j);
      j.onload=l
    }else{
      l()
    }
  }
)(document);

フォローしている人のみリムーブするブックマークレット

フォローしているユーザーのフォローボタンにはfollowingクラスがつきます。

javascript:(function(d){function l(){(function($){$('.following .follow-button').trigger('click');})(jQuery)}if(typeof jQuery=='undefined'){var j=d.createElement('script');j.type='text/javascript';j.src='https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';d.body.appendChild(j);j.onload=l}else{l()}})(document);

ワンラインじゃないとこんな感じ

javascript:(
  function(d){
    function l(){(
      function($){
        $('.following .follow-button').trigger('click');
      }
    )(jQuery)}
    if(typeof jQuery=='undefined'){
      var j=d.createElement('script');
      j.type='text/javascript';
      j.src='https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
      d.body.appendChild(j);
      j.onload=l
    }else{
      l()
    }
  }
)(document);

最後に

ブックマークレットって面白いですね。
手軽にブラウザの単純作業を自動化できます。
JavaScriptが書ける人はね!!

7
8
2

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
7
8