【问题标题】:Whatsapp Web - how to access data now?Whatsapp Web - 现在如何访问数据?
【发布时间】:2018-05-25 07:58:37
【问题描述】:

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

【问题讨论】:

    标签: whatsapp whatsapi


    【解决方案1】:

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

    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,您能否简要评论一下您实际上在做什么来检索 Store 模块?只是看代码我无法弄清楚。
    • 我找到了一个更快的方法..查看我的最新答案。
    【解决方案2】:

    为了详细解释 Pablo 的回答,最初我们使用基于此 How do I require() from the console using webpack? 的代码加载所有 Webpack 模块。

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

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

    你可以在我的 github wiki here找到更多细节

    【讨论】:

      【解决方案3】:

      更快的方法: 我抓住“应用程序”的来源,然后找到商店对象

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-05
        相关资源
        最近更新 更多