1
0

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 1 year has passed since last update.

リクエストURLをすべてコンソールに表示するスクリプト【備忘録】

Last updated at Posted at 2023-07-25

開発者ツールでリクエストURLの一覧を表示させるスクリプト

備忘録として
開発者ツールで表示されるネットワークの項目のリクエストURLをすべてコンソールに表示するためのJavaScriptスクリプト

// 開発者ツールの Network タブに表示されるリクエストURLを取得する
var requests = performance.getEntriesByType('resource').map(entry => entry.name);

// コンソールにリクエストURLを表示する
console.log('リクエストURL一覧:');
requests.forEach((url, index) => console.log(`${index + 1}. ${url}`));

このスクリプトは、performance.getEntriesByType('resource') を使用して、開発者ツールの Network タブに表示されるリソース(リクエストURL)を取得します。それらのURLを console.log を使って順番に表示します。

キーワードで絞って表示させる

上記のコードではすべてのリクエストに対して一覧にするのでキーワードで絞って表示させる場合は以下のコードを使います。

// 開発者ツールの Network タブに表示されるリクエストURLを取得する
var requests = performance.getEntriesByType('resource').map(entry => entry.name);

// 絞り込むキーワード
var keyword = '特定のキーワード'; // ここを変更して絞り込みたいキーワードに置き換える

// コンソールにキーワードに一致するリクエストURLを表示する
console.log(`"${keyword}" に一致するリクエストURL一覧:`);
requests.forEach((url, index) => {
  if (url.includes(keyword)) {
    console.log(`${index + 1}. ${url}`);
  }
});

これで、キーワードで絞ってリスト化することができます。

使い方は、ページを開いた後、開発者ツールのコンソールに上記のスクリプトを貼り付けて実行してください。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?