Skip to content

Instantly share code, notes, and snippets.

@yonixw
Last active Nov 5, 2020
Embed
What would you like to do?
Concurrent WhatsApp Web across devices and windows

Info

Watch the video version : https://www.youtube.com/watch?v=IzZmIpXgZzo

This guide will let you run multiple WhatsApp-Web instances. Please note:

  • Send - every message send will happen as soon as possible
  • Read - Your phone will sync with only 1 instance at a time, to get update, you need to trigger it. My choise is to query a message info (any message)

Note: This guide is for educational porpuses only!!! It might break anyday. Use cautionally.

Step 1 - Sync secrets.

We will setup a WhatsApp-Web connection in all places. Choose one instance and copy your secret keys.

Warning: This secrets gives full access to your account, only share it with poeple you trust!

Open console in your source browser and get those 2 secrets:

  • WABrowserId
    • Run: localStorage.getItem("WABrowserId")
    • Example: "AAAAAAAAAAAAAAAAA==" (including the " at the start and the end)
  • WASecretBundle
    • Run: localStorage.getItem("WASecretBundle")
    • Example: {"key":"<>","encKey":"<>","macKey":"<>"} (including the " at the start and the end)

For all other webrowsers, set the secrets with:

  • WABrowserId
    • Run: localStorage.setItem("WABrowserId",'"AAAAAAAAAAAAAAAAA=="') with your own secret
  • WASecretBundle
    • Run: localStorage.setItem("WASecretBundle",'{"key":"<>","encKey":"<>","macKey":"<>"}') with your own secret

Try to refresh. If it fails, WhatsApp-Web will not recognize and will show "How to connect to your phone..."

Step 2 - Ignore disconnects

In each browser, run this script to ignore disconnect messages:

Note: It will loose effect every page refresh.

_ws = Object.getOwnPropertyDescriptor(WebSocket.prototype,"onmessage")
_ws_new = WebSocket

WebSocket = function (a,b,c,d,e,f)  {
	 Object.defineProperty(_ws_new.prototype,"onmessage",
	 {
		enumerable: true, configurable: true,
		 get:
			_ws.get.bind(this._this),
		 set:
			((fn)=>{
				console.log("Setting up FN")
				_that_fn = fn
				_ws.set.bind(this._this)(
					(function (a,b,c,d,e,f,g) {
						console.log("[0_o] WS Incoming: ",a,b,c,d,e,f,g);
						if (!/disconnect.+replaced/.test((a.data||"").toString().toLowerCase()))
							return _that_fn(a,b,c,d,e,f,g);
						else
							console.log("Ignoring!!!!")
					}).bind(this._this)
				)
			}).bind(this._this)
	})
	this._this = new _ws_new(a,b,c,d,e,f);
	return this._this;
}

Step 3

Now, click "Choose here" in each WhatsApp-Web window until they are all open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment