Bin Chen
Bin Chen

Reputation: 63299

chrome extension: open an website with different account in each tab

I have several accounts for a website and currently I want to write an extension that I can open all the accounts simultaneously in chrome, each tab for one account.

So that means I want each tab with a separate cookie system, is it doable? If so please suggest the API I should use, thanks!

Upvotes: 3

Views: 5529

Answers (3)

Julian Mann
Julian Mann

Reputation: 6476

Go to Chrome Preferences. There is a Users section where you can add users. Each new user will have its own cookie jar, so you can log in to a site as many different users at once. It makes new chrome windows, but it seems you cannot drag a tab onto a window of another user.

enter image description here

Upvotes: 3

Stan
Stan

Reputation: 8768

According to Chrome documentation, you can modify HTTP headers (including cookies) in the onBeforeSendHeaders event handler. So, you need to store new cookies for every account by means of the onHeadersReceived event handler, and then substitute them for every tab in outgoing requests.

There even exists an extension which seems doing almost the thing you want - Chrome Cookie Switcher.

Also I have found an answer that may be helpful for your task: Associate a custom user agent to a specific Google Chrome page/tab.

Upvotes: 2

guillaume
guillaume

Reputation: 1380

I really don't think Chrome allows extensions to do this. If I recall correctly, extensions can inspect and block requests, but they can't modify them, such as changing cookies on the fly for each tab.

I suggest you use the --user-data-dir command-line option of Chrome. It allows you to keep several separate profiles, each in its own directory, and then you only need to start chrome with the proper option:

# run this command to use the first profile
google-chrome --user-data-dir=/home/binchen/my_chrome_profiles/my_profile_1

# run this command to use the second profile
google-chrome --user-data-dir=/home/binchen/my_chrome_profiles/my_profile_2

...

Each profile will be in its own Chrome window, with its own cookie store, instead of its own tab, but it's easier than writing an extension.

Lastly, if the website you're mentioning is Google, you can keep several Google accounts open at the same time.

Upvotes: -1

Related Questions