1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

tweet自動削除スクリプト

Last updated at Posted at 2020-10-01

この記事は以下のような方におすすめです

  • twitter apiを使わずに一括削除したい方
  • 自動化なんとなく好きな方

背景

twitter広告出航したいから昔使っていたアカウント引き継いで出そうかな〜

黒歴史ツイート多いから一括削除するか

まずはtwitter apiを申請してっと...ポチっ

審査中

2日後..
審査中

待てねえ

そうだブラウザ操作して消すか

How to

  1. twitterのプロフィールを開いてください
  2. 以下のコードを開発者モードでconsoleに貼り付けて実行してください
    ツイートタブ、ツイートと返信タブどちらでも使用可能です
var START_TWEET_INDEX = 1;
var MAX_INDEX = 100;
function loop( fn, i, end) {
  return fn(i)
  .then( () => {
    if ( i < end ) {
      return loop( fn, i+1, end)
    }
    else {
      return Promise.resolve('end');
    }
  })
}
function action(i) {
  if (i % 5 === 0) {
    window.scroll(0, 2000);
  }
  return new Promise( (res, rej) => {
    setTimeout( () => {
      const moreList = Array.from(document.querySelectorAll("[aria-label='もっと見る']"));
      moreList[START_TWEET_INDEX].children[0].children[0].click();
      setTimeout(() => {
        document.querySelector("[role='menuitem']").click();
        setTimeout(() => {
          document.querySelectorAll("[data-testid='confirmationSheetConfirm']")[0].click();
        }, 600);
      }, 600);
      res();
    }, 2000)
  })
}
loop(action, 0, MAX_INDEX);

解説

START_TWEET_INDEX

削除を開始したいindex
1つ目のツイートだけは残したい!!そんな方は
START_TWEET_INDEX = 1

MAX_INDEX

START_TWEET_INDEXから何個目までツイートを消したいかを定義する
とりあえず全部消したい方は適当に
MAX_INDEX = 1000000;
とかにしときましょう

まとめ

これで清廉潔白な状態でtwitter adを始められますね
他にもこんな記事も書いてるので自動化楽しんでください

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?