4

It used to be possible to access http://web.whatsapp.com/ with the Store object in JavaScript. A few hours ago, this stopped working. How does it update chat data now? It must save the data somewhere.

user418051518
  • 43
  • 1
  • 4

3 Answers3

6

I'm using this to get the Store again:

setTimeout(function() {
// Returns promise that resolves to all installed modules
function getAllModules() {
    return new Promise((resolve) => {
        const id = _.uniqueId("fakeModule_");
        window["webpackJsonp"](
            [],
            {
                [id]: function(module, exports, __webpack_require__) {
                    resolve(__webpack_require__.c);
                }
            },
            [id]
        );
    });
}

var modules = getAllModules()._value;

//  Automatically locate modules
for (var key in modules) {
 if (modules[key].exports) {
        if (modules[key].exports.default) {
            if (modules[key].exports.default.Wap) {
                store_id = modules[key].id.replace(/"/g, '"');
            }
        }
    }
 }

}, 5000);

function _requireById(id) {
return webpackJsonp([], null, [id]);
}
// Module IDs
var store_id = 0;
var Store = {};

function init() {
 Store = _requireById(store_id).default;
 console.log("Store is ready" + Store);
}

setTimeout(function() {
 init();
}, 7000);

Just copy&paste on the console and wait for the message "Store is ready". Enjoy!

  • Thanks Pablo, could you briefly comment on what you are actually doing to retrieve the Store module? I'm unable to figure it out just looking at the code. – cprcrack Jun 20 '18 at 15:59
  • I found a faster method.. check my latest answer. – Zibri Feb 18 '19 at 07:57
4

To explain Pablo's answer in detail, initially we load all the Webpack modules using code based on this How do I require() from the console using webpack?.

Essentially, the getAllModules() returns a promise with all the installed modules in Webpack. Each module can be required by ID using the _requireById(id) which uses the webpackJsonp(...) function that is exposed by Webpack.

Once the modules are loaded, we need to identify which id corresponds to the Store. We search for a module containing exports.default.Wap and assign it's id as the Store ID.

You can find more details on my github wiki here

Rob
  • 26,989
  • 16
  • 82
  • 98
0

A faster method: I grab the source of the "app" and find the store object then

I save it in ZStore global variable. :D

!function(){for(var t of document.getElementsByTagName("script"))t.src.indexOf("/app.")>0&&fetch(t.src,{method:"get"}).then(function(t){return t.text().then(function(t){var e=t.indexOf('var a={};t["default"]')-89;window.ZStore=window.webpackJsonp([],null,JSON.stringify(t.substr(e,10))).default})})}();

window.ZStore will contain the object.

Non minified version:

(function() {
    function getStore(url) {
        fetch(url, {
            "method": 'get'
        }).then(function(response) {
            return response.text().then(function(data) {
                var offset = data.indexOf('var a={};t["default"]') - 89;
                window.ZStore = window.webpackJsonp([], null, JSON.stringify(data.substr(offset, 10))).default
            });
        });
    }
    for (var e of document.getElementsByTagName("script")) {
        if (e.src.indexOf("/app.") > 0) getStore(e.src);
    }
})();
Zibri
  • 9,096
  • 3
  • 52
  • 44