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

4

以前可以使用JavaScript中的Store对象访问http://web.whatsapp.com/。几个小时前,这种方法停止工作了。现在它如何更新聊天数据?它一定会把数据保存在某个地方。

3个回答

6
我用这个来再次获取Store:
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,你能简要地评论一下你实际上是如何检索Store模块的吗?仅仅通过查看代码,我无法弄清楚它的工作原理。 - cprcrack
我找到了一种更快的方法,请查看我的最新答案。 - Zibri

4
为了详细解释Pablo的答案,我们首先使用基于如何使用webpack从控制台进行require()的代码加载所有Webpack模块。
实质上,getAllModules()会返回一个承诺,其中包含Webpack中安装的所有模块。 可以使用_requireById(id)通过ID来要求每个模块,该方法使用Webpack公开的webpackJsonp (...)函数。
一旦加载了模块,我们需要确定哪个id对应于Store。 我们搜索包含exports.default.Wap的模块,并将其id分配为Store ID。
您可以在我的github wiki 此处找到更多详细信息。

0
更快的方法: 我获取“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);
    }
})();

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接