Whatsapp Web - 现在如何访问数据?

Whatsapp Web - how to access data now?

以前可以使用 JavaScript 中的 Store 对象访问 http://web.whatsapp.com/。几个小时前,它停止工作了。它现在如何更新聊天数据?它必须将数据保存在某处。

我正在使用它再次获取商店:

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);

只需在控制台上复制粘贴并等待消息 "Store is ready"。 享受吧!

为了详细解释 Pablo 的回答,最初我们使用基于此 的代码加载所有 Webpack 模块。

本质上,getAllModules() returns 对 Webpack 中所有已安装模块的承诺。使用 _requireById(id) 可以通过 ID 要求每个模块,它使用 Webpack 公开的 webpackJsonp(...) 函数。

加载模块后,我们需要确定哪个 id 对应于商店。我们搜索包含 exports.default.Wap 的模块并将其分配给 id 作为 Store ID。

您可以在我的 github wiki here

上找到更多详细信息

更快的方法: 我抓取 "app" 的来源,然后找到存储对象

我保存在ZStore全局变量中。 :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 将包含对象。

非缩小版:

(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);
    }
})();