├── wapi.js └── zstore.js /wapi.js: -------------------------------------------------------------------------------- 1 | const Api = {} 2 | 3 | const initApi = () => { 4 | return new Promise((resolve, reject) => { 5 | /* 6 | * There are 2 stores that need initializing: WLAPStore and WLAPWAPStore. 7 | * From the WA DOM we extract 2 scrips, download and regex them to search 8 | * for the correct function names in the webpacked WA javascripts. * 9 | * 10 | * */ 11 | 12 | const scripts = document.getElementsByTagName('script') 13 | const regexApp = /\/app\..+.js/ 14 | const regexApp2 = /\/app2\..+.js/ 15 | let appScriptUrl, app2ScriptUrl 16 | 17 | // Derive script urls 18 | for (let i = 0; i < scripts.length; i++) { 19 | const src = scripts[i].src 20 | if (regexApp.exec(src) != null) { 21 | appScriptUrl = src 22 | } 23 | 24 | if (regexApp2.exec(src) != null) { 25 | app2ScriptUrl = src 26 | } 27 | } 28 | 29 | // Download scripts, regex them and assign store 30 | fetch(appScriptUrl).then(e => { 31 | const reader = e.body.getReader() 32 | let js_src = "" 33 | 34 | return reader.read().then(function readMore({done, value}) { 35 | const td = new TextDecoder("utf-8") 36 | const str_value = td.decode(value) 37 | if (done) { 38 | js_src += str_value 39 | const regExDynNameStore = /Wap:[a-z]\('"(\w+)"'\)/ 40 | const res = regExDynNameStore.exec(js_src) 41 | const funcName = res[1] 42 | window.webpackJsonp([], {[funcName]: (x, y, z) => {Api.WLAPWAPStore = z('"' + funcName + '"')}}, funcName) 43 | return 44 | } 45 | 46 | js_src += str_value 47 | return reader.read().then(readMore) 48 | 49 | }) 50 | 51 | }).then(() => { 52 | fetch(app2ScriptUrl).then(e => { 53 | const reader = e.body.getReader() 54 | let js_src = "" 55 | 56 | return reader.read().then(function readMore({done, value}) { 57 | const td = new TextDecoder("utf-8") 58 | const str_value = td.decode(value) 59 | if (done) { 60 | js_src += str_value 61 | const regExDynNameStore = /'"(\w+)"':function\(e,t,a\)\{\"use strict\";e\.exports=\{AllStarredMsgs:/ 62 | const res = regExDynNameStore.exec(js_src) 63 | const funcName = res[1] 64 | 65 | window.webpackJsonp([], {[funcName]: (x, y, z) => Api.WLAPStore = z('"' + funcName + '"')}, funcName) 66 | resolve() 67 | return 68 | } 69 | 70 | js_src += str_value 71 | return reader.read().then(readMore) 72 | 73 | }) 74 | 75 | }) 76 | }) 77 | 78 | 79 | }) 80 | } 81 | 82 | const getApi = () => { 83 | if (Api && typeof Api.WLAPStore === "object" && typeof Api.WLAPWAPStore === "object") { 84 | return Api 85 | } else { 86 | console.error('WWapApi is not initialized, call initApi() first') 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /zstore.js: -------------------------------------------------------------------------------- 1 | !function(){const o=function(e){o.mID=Math.random().toString(36).substring(7);o.mObj={};o.cArr=[];o.mGet=null;e?o.debug=!0:window.mRdebug?o.debug=!0:o.debug=!1;o.log=function(e){o.debug&&console.warn(`[moduleRaid] ${e}`)};o.args=[[[0],[function(e,n,t){mCac=t.c;Object.keys(mCac).forEach(function(e){o.mObj[e]=mCac[e].exports});o.cArr=t.m;o.mGet=t}]],[[1e3],{[o.mID]:function(e,n,t){mCac=t.c;Object.keys(mCac).forEach(function(e){o.mObj[e]=mCac[e].exports});o.cArr=t.m;o.mGet=t}},[[o.mID]]]];fillModuleArray=function(){if("function"==typeof webpackJsonp)o.args.forEach(function(e,n){try{webpackJsonp(...e)}catch(e){o.log(`moduleRaid.args[${n}] failed: ${e}`)}});else try{webpackJsonp.push(o.args[1])}catch(e){o.log(`Pushing moduleRaid.args[1] into webpackJsonp failed: ${e}`)}if(0==o.mObj.length){mEnd=!1;mIter=0;if(!webpackJsonp([],[],[mIter]))throw Error("Unknown Webpack structure");for(;!mEnd;)try{o.mObj[mIter]=webpackJsonp([],[],[mIter]);mIter++}catch(o){mEnd=!0}}};fillModuleArray();get=function(e){return o.mObj[e]};findModule=function(e){results=[];modules=Object.keys(o.mObj);modules.forEach(function(n){mod=o.mObj[n];if("undefined"!=typeof mod){if("object"==typeof mod.default)for(key in mod.default)key==e&&results.push(mod);for(key in mod)key==e&&results.push(mod)}});return results};findFunction=function(e){if(0==o.cArr.length)throw Error("No module constructors to search through!");results=[];if("string"==typeof e)o.cArr.forEach(function(n,t){n.toString().includes(e)&&results.push(o.mObj[t])});else{if("function"!=typeof e)throw new TypeError("findFunction can only find via string and function, "+typeof e+" was passed");modules=Object.keys(o.mObj);modules.forEach(function(n,t){mod=o.mObj[n];e(mod)&&results.push(o.mObj[t])})}return results};return{modules:o.mObj,constructors:o.cArr,findModule:findModule,findFunction:findFunction,get:o.mGet?o.mGet:get}};"object"==typeof module&&module.exports?module.exports=o:window.mR=o();window.Store=window.mR.findModule("Conn")[0].default}(); 2 | // window.Store contains WhatsAppWebApi 3 | --------------------------------------------------------------------------------