mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-19 20:19:14 +00:00
Load moduleRaid from GitHub
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -194,6 +194,10 @@
|
|||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"moduleraid": {
|
||||||
|
"version": "git+https://github.com/pixeldesu/moduleRaid.git#113b90ec709f5d4601db8d5e96b1155aa772ae97",
|
||||||
|
"from": "git+https://github.com/pixeldesu/moduleRaid.git"
|
||||||
|
},
|
||||||
"ms": {
|
"ms": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pedroslopez/whatsapp-web.js#readme",
|
"homepage": "https://github.com/pedroslopez/whatsapp-web.js#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"moduleraid": "git+https://github.com/pixeldesu/moduleRaid.git",
|
||||||
"puppeteer": "^1.12.2"
|
"puppeteer": "^1.12.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const puppeteer = require('puppeteer');
|
const puppeteer = require('puppeteer');
|
||||||
|
const moduleRaid = require('moduleraid/moduleraid');
|
||||||
|
|
||||||
const Util = require('./util/Util');
|
const Util = require('./util/Util');
|
||||||
const { WhatsWebURL, UserAgent, DefaultOptions, Events } = require('./util/Constants');
|
const { WhatsWebURL, UserAgent, DefaultOptions, Events } = require('./util/Constants');
|
||||||
const { ExposeStore, LoadExtraProps, LoadCustomSerializers } = require('./util/Injected');
|
const { ExposeStore, LoadExtraProps, LoadCustomSerializers } = require('./util/Injected');
|
||||||
const ChatFactory = require('./factories/ChatFactory');
|
const ChatFactory = require('./factories/ChatFactory');
|
||||||
const Chat = require('./structures/Chat');
|
const Chat = require('./structures/Chat');
|
||||||
const Message = require('./structures/Message')
|
const Message = require('./structures/Message');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starting point for interacting with the WhatsApp Web API
|
* Starting point for interacting with the WhatsApp Web API
|
||||||
@@ -76,7 +78,7 @@ class Client extends EventEmitter {
|
|||||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, {timeout: 0});
|
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, {timeout: 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
await page.evaluate(ExposeStore);
|
await page.evaluate(ExposeStore, moduleRaid.toString());
|
||||||
|
|
||||||
// Get session tokens
|
// Get session tokens
|
||||||
const localStorage = JSON.parse(await page.evaluate(() => {
|
const localStorage = JSON.parse(await page.evaluate(() => {
|
||||||
|
|||||||
@@ -3,163 +3,9 @@
|
|||||||
/**
|
/**
|
||||||
* Exposes the internal Store to the WhatsApp Web client
|
* Exposes the internal Store to the WhatsApp Web client
|
||||||
*/
|
*/
|
||||||
exports.ExposeStore = () => {
|
exports.ExposeStore = (moduleRaidStr) => {
|
||||||
// CREDITS: moduleRaid by PixelDesu
|
eval("var moduleRaid = " + moduleRaidStr);
|
||||||
// https://github.com/pixeldesu/moduleRaid/blob/master/moduleraid.js
|
window.mR = moduleRaid();
|
||||||
|
|
||||||
const moduleRaid = function (debug) {
|
|
||||||
moduleRaid.mID = Math.random().toString(36).substring(7);
|
|
||||||
moduleRaid.mObj = {};
|
|
||||||
moduleRaid.cArr = [];
|
|
||||||
moduleRaid.mGet = null;
|
|
||||||
|
|
||||||
if (debug) {
|
|
||||||
moduleRaid.debug = true;
|
|
||||||
} else if (window.mRdebug) {
|
|
||||||
moduleRaid.debug = true;
|
|
||||||
} else {
|
|
||||||
moduleRaid.debug = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
moduleRaid.log = function (message) {
|
|
||||||
if (moduleRaid.debug) {
|
|
||||||
console.warn(`[moduleRaid] ${message}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
moduleRaid.args = [
|
|
||||||
[[0], [function(e, t, i) {
|
|
||||||
mCac = i.c;
|
|
||||||
Object.keys(mCac).forEach (function(mod) {
|
|
||||||
moduleRaid.mObj[mod] = mCac[mod].exports;
|
|
||||||
})
|
|
||||||
moduleRaid.cArr = i.m;
|
|
||||||
moduleRaid.mGet = i;
|
|
||||||
}]],
|
|
||||||
[[1e3], {[moduleRaid.mID]: function(e, t, i) {
|
|
||||||
mCac = i.c;
|
|
||||||
Object.keys(mCac).forEach (function(mod) {
|
|
||||||
moduleRaid.mObj[mod] = mCac[mod].exports;
|
|
||||||
})
|
|
||||||
moduleRaid.cArr = i.m;
|
|
||||||
moduleRaid.mGet = i;
|
|
||||||
}}, [[moduleRaid.mID]]]
|
|
||||||
]
|
|
||||||
|
|
||||||
fillModuleArray = function() {
|
|
||||||
if (typeof webpackJsonp === 'function') {
|
|
||||||
moduleRaid.args.forEach(function (argument, index) {
|
|
||||||
try {
|
|
||||||
webpackJsonp(...argument);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
moduleRaid.log(`moduleRaid.args[${index}] failed: ${err}`);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
webpackJsonp.push(moduleRaid.args[1]);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
moduleRaid.log(`Pushing moduleRaid.args[1] into webpackJsonp failed: ${err}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (moduleRaid.mObj.length == 0) {
|
|
||||||
mEnd = false;
|
|
||||||
mIter = 0;
|
|
||||||
|
|
||||||
if (!webpackJsonp([],[],[mIter])) {
|
|
||||||
throw Error('Unknown Webpack structure');
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!mEnd) {
|
|
||||||
try {
|
|
||||||
moduleRaid.mObj[mIter] = webpackJsonp([],[],[mIter]);
|
|
||||||
mIter++;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
mEnd = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fillModuleArray()
|
|
||||||
|
|
||||||
get = function get (id) {
|
|
||||||
return moduleRaid.mObj[id]
|
|
||||||
}
|
|
||||||
|
|
||||||
findModule = function findModule (query) {
|
|
||||||
results = [];
|
|
||||||
modules = Object.keys(moduleRaid.mObj);
|
|
||||||
|
|
||||||
modules.forEach(function(mKey) {
|
|
||||||
mod = moduleRaid.mObj[mKey];
|
|
||||||
|
|
||||||
if (typeof mod !== 'undefined') {
|
|
||||||
if (typeof mod.default === 'object') {
|
|
||||||
for (key in mod.default) {
|
|
||||||
if (key == query) results.push(mod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (key in mod) {
|
|
||||||
if (key == query) results.push(mod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
findFunction = function(query) {
|
|
||||||
if (moduleRaid.cArr.length == 0) {
|
|
||||||
throw Error('No module constructors to search through!');
|
|
||||||
}
|
|
||||||
|
|
||||||
results = [];
|
|
||||||
|
|
||||||
if (typeof query === 'string') {
|
|
||||||
moduleRaid.cArr.forEach(function (ctor, index) {
|
|
||||||
if (ctor.toString().includes(query)) {
|
|
||||||
results.push(moduleRaid.mObj[index]);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (typeof query === 'function') {
|
|
||||||
modules = Object.keys(moduleRaid.mObj);
|
|
||||||
|
|
||||||
modules.forEach(function(mKey, index) {
|
|
||||||
mod = moduleRaid.mObj[mKey];
|
|
||||||
|
|
||||||
if (query(mod)) {
|
|
||||||
results.push(moduleRaid.mObj[index]);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
throw new TypeError('findFunction can only find via string and function, ' + (typeof query) + ' was passed');
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
modules: moduleRaid.mObj,
|
|
||||||
constructors: moduleRaid.cArr,
|
|
||||||
findModule: findModule,
|
|
||||||
findFunction: findFunction,
|
|
||||||
get: moduleRaid.mGet ? moduleRaid.mGet : get
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof module === 'object' && module.exports) {
|
|
||||||
module.exports = moduleRaid;
|
|
||||||
} else {
|
|
||||||
window.mR = moduleRaid();
|
|
||||||
}
|
|
||||||
|
|
||||||
window.Store = window.mR.findModule("Conn")[0].default;
|
window.Store = window.mR.findModule("Conn")[0].default;
|
||||||
window.Store.SendMessage = window.mR.findModule("sendTextMsgToChat")[0].sendTextMsgToChat;
|
window.Store.SendMessage = window.mR.findModule("sendTextMsgToChat")[0].sendTextMsgToChat;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user