tk3.biz
ブログ一覧に戻る Back to Blog

Chrome拡張機能「Switch Browser Data」を作ってみた I Built a Chrome Extension: Switch Browser Data

はじめに

Webアプリ開発では、管理者・一般ユーザーなど複数のアカウントでテストする場面が頻繁にあります。しかも一般ユーザーにも権限レベルが複数ある場合、アカウントの種類はさらに増えます。

以前は切り替えのたびに「ログアウト → 別アカウントでログイン」を繰り返していました。地味に時間がかかるうえ、テンポが崩れてストレスになっていました。

既存ツールを使わなかった理由

「ブラウザのCookieを切り替えるツール」を探したことがある方なら、いくつか選択肢が見つかることはご存知かと思います。ただ、気になったのが信頼性の問題です。

CookieにはログインセッションIDが含まれています。つまり、Cookieを扱うツールに悪意があれば、そのデータを使ってアカウントに侵入することが理論上は可能です。

クローズドソースのツールは中身を確認できません。「このツールは安全か?」という問いに答えられないまま使い続けることに、どうしても抵抗がありました。

作ったもの:Switch Browser Data

そこで、自分で作ることにしました。コードをOSSで公開することで、「中身を見て確認できる」状態にすることが目的の一つでもあります。

Switch Browser Data は、ドメインごとにブラウザデータをスナップショット保存して、ワンクリックで切り替えられるChrome / Edge拡張機能です。

対応しているデータは以下のとおりです。

データ種別内容
Cookieログインセッションなど
localStorageブラウザに永続保存されるデータ
sessionStorageタブを閉じると消えるデータ
IndexedDB構造化データの保存

すべてのデータはデバイス内にのみ保存され、外部に送信されることはありません。

使い方

1. スナップショットを保存する

ログイン済みの状態でポップアップを開き、スナップショット名を入力して保存します。アカウントごとに「管理者」「一般ユーザーA」のように名前をつけておくと管理しやすいです。

2. ワンクリックで切り替える

ドロップダウンから切り替えたいスナップショットを選択するだけです。ページをリロードすれば、そのアカウントの状態が復元されます。

ドメインごとに管理されるため、別のサービスのデータに影響しません。

ソースコード

コードはGitHubで公開しています。

https://github.com/istb16/switch-browser-data-extension

MITライセンスです。使い方の確認や、不審な挙動がないかの検証にご活用ください。

まとめ

  • 複数アカウントの切り替えを「ログアウト→ログイン」なしにワンクリックで行える
  • Cookieはログインセッションを含むため、信頼できるツールが必要だと判断して自作した
  • OSSで公開しているので、コードを見て安全性を確認できる
  • Chrome / Edge 両対応、データはすべてローカル保存

Introduction

When developing a web app, I often need to test with multiple accounts, such as an administrator and a regular user. And when regular users have several permission levels, the number of account types grows even more.

I used to go through “log out → log in with another account” every time I switched. It quietly ate up time and broke my rhythm, which got stressful.

Why I Didn’t Use an Existing Tool

If you’ve ever looked for “a tool to switch browser cookies,” you know there are a few options out there. What bothered me, though, was trust.

Cookies contain login session IDs. That means if a tool that handles cookies were malicious, it could in theory use that data to break into your accounts.

With closed-source tools, you can’t check what’s inside. I just couldn’t get comfortable using a tool while being unable to answer the question “Is this tool safe?”

What I Built: Switch Browser Data

So I decided to build one myself. One of the goals was to publish the code as open source so that anyone can look inside and check it.

Switch Browser Data is a Chrome / Edge extension that saves snapshots of browser data per domain and lets you switch between them with one click.

It supports the following data:

Data typeWhat it holds
CookieLogin sessions and the like
localStorageData stored persistently in the browser
sessionStorageData that disappears when the tab is closed
IndexedDBStructured data storage

All data is stored only on your device and is never sent anywhere.

How to Use It

1. Save a Snapshot

While logged in, open the popup, enter a snapshot name, and save. Naming them per account, like “Admin” or “Regular user A,” makes them easy to manage.

2. Switch with One Click

Just pick the snapshot you want from the dropdown. Reload the page, and that account’s state is restored.

Data is managed per domain, so it doesn’t affect other services’ data.

Source Code

The code is public on GitHub.

https://github.com/istb16/switch-browser-data-extension

It’s under the MIT license. Feel free to use it to see how it works or to verify that it doesn’t do anything suspicious.

Summary

  • Switch between multiple accounts with one click, without “log out → log in”
  • Cookies include login sessions, so I decided I needed a tool I could trust and built my own
  • It’s open source, so you can read the code and check that it’s safe
  • Works on both Chrome and Edge, and all data is stored locally

関連記事 Related Posts

dev-orchestra で役割ごとに決まった指示を渡してみた Giving dev-orchestra Standing Instructions per Role

dev-orchestra 1.2.1 で入った instructions を試しました。implementer やレビュアーへの決まった指示をリポジトリに書いておくと、毎回のプロンプトに入ります。どう表示され、どこに入り、指示を変える変更がどう扱われるかを、実際の出力で確かめます。 I tried instructions, added in dev-orchestra 1.2.1. Standing instructions for the implementer or reviewers written in the repository go into every prompt. I check, with real output, how they are shown, where they go, and how a change to the instructions is treated.

[Released] dev-orchestra: 作業単位の並列実行と役割ごとの指示を追加 v1.1.0 - v1.2.1 [Released] dev-orchestra: Parallel Work Units and Per-Role Instructions v1.1.0 - v1.2.1

dev-orchestra の v1.1.0 から v1.2.1 までの変更をまとめました。計画を作業単位に分けて並べて走らせる機能、役割ごとに決まった指示を渡す機能、設計の前の質問、進み具合の報告の設定が入りました。Windows で出力を取り込んでいる人は、文字コードの変更に注意してください。 A roundup of dev-orchestra's changes from v1.1.0 to v1.2.1: running a plan as work units side by side, standing instructions per role, questions before the design, and settings for progress reports. If you capture its output on Windows, note the encoding change.

dev-orchestra の作業単位で、計画を分けて並べて実装してみた Splitting a Plan into dev-orchestra Work Units and Implementing Them Side by Side

dev-orchestra 1.2.0 で入った作業単位を試しました。計画に ## Units を書き、2 つの作業単位を別々の git worktree で並べて Claude に実装させ、作業ツリーへマージし、最後の統合の作業単位をその場で走らせるまでを、実際のコマンドと出力で追います。 I tried the work units added in dev-orchestra 1.2.0. I wrote a ## Units section in a plan, had Claude implement two units side by side in separate git worktrees, merged them into the working tree, and ran the final integration unit in place, with the actual commands and output.