4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

InstagramのDMを保存する方法

Last updated at Posted at 2020-09-27

背景

最近は、LINEよりもインスタグラムのDMを使用する方が増えてきたようです。
しかし、インスタグラムのDMはメッセージを検索したり、遡りすることができません。
そこで、インスタグラムの画面から、JavaScriptを実行して、テキストとして保存する方法をご紹介します。(利用規約的にもセーフだと思います。アウトだったら消します)

手順

手順を示します。途中で失敗したら、ブラウザの更新ボタンを押して、やり直してください。

  1. PCブラウザで保存したいDM画面を開きます。https://www.instagram.com/direct/t/[番号]
  2. ブラウザの検証機能を開き、コンソール画面を開きます。
  3. 以下のコードを実行して、保存したいところまで遡ります。(量が多いと時間かかります)
timer = setInterval(() => {
  document.getElementsByClassName('x78zum5 xdt5ytf x1iyjqo2 xs83m0k x1xzczws x6ikm8r x1odjw0f x1n2onr6 xh8yej3 x16o0dkt')[0].scrollBy(0, -window.innerHeight);
}, 100)

4.保存したいところまで来たら、以下のコードで止めます。

clearInterval(timer);

5.テキストファイルとして保存します。

out = document.getElementsByClassName('x78zum5 xdt5ytf x1iyjqo2 xs83m0k x1xzczws x6ikm8r x1odjw0f x1n2onr6 xh8yej3 x16o0dkt')[0].innerText
let blob = new Blob([out],{type:"text/plan"});
let link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'out.txt';
link.click();
4
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?