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



过去可以在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);

只需在控制台上复制并粘贴,然后等待消息"商店已准备就绪"。 享受!

为了详细解释 Pablo 的答案,最初我们使用基于此的代码加载所有 Webpack 模块 如何使用 webpack 从控制台 require(( ?

从本质上讲,getAllModules()返回一个承诺,其中包含 Webpack 中所有已安装的模块。每个模块都可以使用 ID 来要求,该_requireById(id)使用 Webpack 公开的webpackJsonp(...)函数。

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

你可以在我的github维基上找到更多详细信息

这里

更快的方法: 我抓住"应用程序"的源代码并找到商店对象

我把它保存在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})})}();

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

最新更新