Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
setTimeout(function() {
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;
for (var key in modules) {
if (modules[key].exports) {
if (modules[key].exports.createFromData) {
createFromData_id = modules[key].i.replace(/"/g, '"');
}
if (modules[key].exports.prepRawMedia) {
prepareRawMedia_id = modules[key].i.replace(/"/g, '"');
}
if (modules[key].exports.default) {
if (modules[key].exports.default.Wap) {
store_id = modules[key].i.replace(/"/g, '"');
}
}
if (modules[key].exports.sendTextMsgToChat) {
chat_id = modules[key].i.replace(/"/g, '"');
}
}
}
}, 2000);
function _requireById(id) {
return webpackJsonp([], null, [id]);
}
var createFromData_id = 0;
var prepareRawMedia_id = 0;
var store_id = 0;
var chat_id = 0;
function fixBinary (bin) {
var length = bin.length;
var buf = new ArrayBuffer(length);
var arr = new Uint8Array(buf);
for (var i = 0; i < length; i++) {
arr[i] = bin.charCodeAt(i);
}
return buf;
}
var send_media;
window.send_media = function(jid, link, caption, msg_id, content_type) {
var file = "";
var createFromDataClass = _requireById(createFromData_id)["default"];
var prepareRawMediaClass = _requireById(prepareRawMedia_id).prepRawMedia;
window.Store.Chat.find(jid).then((chat) => {
var img_b64 = link;
var base64 = img_b64.split(',')[1];
var type = img_b64.split(',')[0];
type = type.split(';')[0];
type = type.split(':')[1];
var binary = fixBinary(atob(base64));
var blob = new Blob([binary], {type: type});
var random_name = Math.random().toString(36).substr(2, 5);
file = new File([blob], random_name, {
type: type,
lastModified: Date.now()
});
var temp = createFromDataClass.createFromData(file, file.type);
var rawMedia = prepareRawMediaClass(temp, {});
var target = _.filter(window.Store.Msg.models, (msg) => {
return msg.id.id === msg_id;
})[0];
var textPortion = {
caption: caption,
mentionedJidList: [],
quotedMsg: target
};
rawMedia.sendToChat(chat, textPortion);
});
}
var Store = {};
function init() {
window.Store = _requireById(store_id).default;
window.Store.sendTextMsgToChat = _requireById(chat_id).sendTextMsgToChat;
console.log("Store is ready");
console.log(window.Store);
window.send_media("91xxxxxxxxxx@c.us", "data:image/png;base64,iVBORw0KG..........sda=", "test messsage", null, null);
}
setTimeout(function() {
init();
}, 5000);
@phpRajat

This comment has been minimized.

Copy link
Owner Author

phpRajat commented Jul 26, 2018

for send media use below function
window.send_media("jid", "file base64 code", "test messsage", null, null);

@NelsonGaldeman

This comment has been minimized.

Copy link

NelsonGaldeman commented Jul 27, 2018

Well done!

@brnmonteiro

This comment has been minimized.

Copy link

brnmonteiro commented Jul 30, 2018

A little doubt, how often wpp change their code to prevent this?

@humbertorodrigues

This comment has been minimized.

Copy link

humbertorodrigues commented Aug 7, 2018

You're simple THE BEST!!!

@MrKcyre

This comment has been minimized.

Copy link

MrKcyre commented Aug 24, 2018

Awesome code! Thanks! I was wondering if u guys know how to send a user mention..?

@Mega4alik

This comment has been minimized.

Copy link

Mega4alik commented Aug 27, 2018

Hello, how to use this function?

Can it be used as a separate javascript piece of code on web version of whatsapp?

Thank you

@sergio7chaccuro

This comment has been minimized.

Copy link

sergio7chaccuro commented Sep 3, 2018

Sorry we get follow error when executing:
progress.73d3ea869f2050b7c85e71112ff48ab9.js:2 Uncaught TypeError: Cannot read property 'call' of undefined
at a (progress.73d3ea869f2050b7c85e71112ff48ab9.js:2)
at window.webpackJsonp (progress.73d3ea869f2050b7c85e71112ff48ab9.js:2)
at _requireById (:40:9)
at init (:95:17)
at :102:2

Could you help us?

Thanks
Regards

@siddhanth

This comment has been minimized.

Copy link

siddhanth commented Sep 6, 2018

Awesome this helps. I am using this to send web link, but the preview (og-image) and all is not loading up
It just goes as a simple link, without any preview. Is there a way we can handle that as well

@Suebersson

This comment has been minimized.

Copy link

Suebersson commented Sep 10, 2018

Oi boa tarde, o código funciona quando é executado dentro do console, mais quando tento executar em uma Extensão do Google chrome gera erros. Alguém pode me ajudar?

Hi good afternoon, the code works when it is saved inside the console, more when it is done in a Google chrome extension generates errors. Can someone help me?

git hub

@phpRajat

This comment has been minimized.

Copy link
Owner Author

phpRajat commented Sep 24, 2018

Hello, how to use this function?

Can it be used as a separate javascript piece of code on web version of whatsapp?

Thank you

Paste this code in browser console

@Suebersson

This comment has been minimized.

Copy link

Suebersson commented Oct 1, 2018

I'm trying to run the code inside a Chrome extension and it's generating errors.

Would you have a version that would run on both the console and a Chrome extension?

@apnerve

This comment has been minimized.

Copy link

apnerve commented Nov 15, 2018

This is brilliant! Can't thank you enough for this @phpRajat

@Kontr3X

This comment has been minimized.

Copy link

Kontr3X commented Nov 27, 2018

for example i want to kick any new member in a group instantly when he join the group from an public link that has an special number (to example +1 country Numbers) to prevent bots spam us, how can i done this? what is the kick function @phpRajat

@domgjntoki

This comment has been minimized.

Copy link

domgjntoki commented Jan 8, 2019

How have you discovered what the javascript functions do and work, and their args? There are so many functions in the console that I am willing to use, but and don't know how to use them

@gobiv86

This comment has been minimized.

Copy link

gobiv86 commented Jan 10, 2019

@phpRajat, great job! It is really useful to automate whatsapp web function via JavaScript. Thank you for the code :) is there any way, we can subscribe to event when user send message to us?

@Mirog13

This comment has been minimized.

Copy link

Mirog13 commented Jan 23, 2019

@phpRajat please help with the code for chrome extension

@eft0stuff

This comment has been minimized.

Copy link

eft0stuff commented Jan 23, 2019

it's possible to attach a PDF file ? i read the arguments in send_media() but dont full understand the link variable splits the function do.

@humbertorodrigues

This comment has been minimized.

Copy link

humbertorodrigues commented Feb 13, 2019

Any idea how can I send a message to a number which is not my contact? This way do not work

@gitanderson

This comment has been minimized.

Copy link

gitanderson commented Feb 20, 2019

@phpRajat Do you know if it's possible to send VCARD in the similar way?

@keithlsp

This comment has been minimized.

Copy link

keithlsp commented Feb 23, 2019

Hi, What is the meaning of "jid" , and how to get it , many thanks!!

@mosaw

This comment has been minimized.

Copy link

mosaw commented Feb 23, 2019

@humbertorodrigues
yes I can send msgs to numbers which are not my contacts
and to groups also
this is my gmail : sawyhawy@gmail.com
ytube: https://www.youtube.com/channel/UCL1JCbtI7XME89NkgqKMb3g

@phpRajat

This comment has been minimized.

Copy link
Owner Author

phpRajat commented May 20, 2019

Any idea how can I send a message to a number which is not my contact? This way do not work

Here is code for send message to new contact:

Store.Contact.find("91XXXXXXXXXX@c.us").then((x) => { Store.Chat.find(x.id).then((user) => { user.sendMessage("Hi there"); }); });

And here is code to send message to existing chat:

Store.Chat.find("91XXXXXXXXXX@c.us").then((user) => { user.sendMessage("hello"); });

I hope this helps you. :)

@phpRajat

This comment has been minimized.

Copy link
Owner Author

phpRajat commented May 20, 2019

Hi, What is the meaning of "jid" , and how to get it , many thanks!!

jid is contact number like if you want to send message to 919898989898 then jid is 919898989898@c.us

@phpRajat

This comment has been minimized.

Copy link
Owner Author

phpRajat commented May 20, 2019

it's possible to attach a PDF file ? i read the arguments in send_media() but dont full understand the link variable splits the function do.

Hmm. I just tried with image. Actually in this function first i convert image file to base64 then convert to blob and then upload to whatsapp.
So same in pdf first you have to convert in base64 and then try this function .

Tips: base64 look like this : data:image/png;base64,iVBORw0KG..........sda=
Here you can convert file to base64 https://www.browserling.com/tools/file-to-base64

@phpRajat

This comment has been minimized.

Copy link
Owner Author

phpRajat commented May 20, 2019

@phpRajat, great job! It is really useful to automate whatsapp web function via JavaScript. Thank you for the code :) is there any way, we can subscribe to event when user send message to us?

Yes you can activate listener:
Store.Msg.on('add', (newMessage) => { if (newMessage && newMessage.isNewMsg && !newMessage.isSentByMe) { console.log(newMessage); } });

@phpRajat

This comment has been minimized.

Copy link
Owner Author

phpRajat commented May 20, 2019

for example i want to kick any new member in a group instantly when he join the group from an public link that has an special number (to example +1 country Numbers) to prevent bots spam us, how can i done this? what is the kick function @phpRajat

Here is simple code to remove particular participant from group:
const metaDataGroup = Store.GroupMetadata.get(idGroup);
const participant = metaDataGroup.participants.get(idParticipant);
metaDataGroup.participants.removeParticipants([participant]).then((ret)=>{ const check = metaDataGroup.participants.get(idParticipant); if (check === undefined){ done(true); return true; } done(false); return false; })

idGroup '0000000000-00000000@g.us'
idParticipant '000000000000@c.us'

@John4932

This comment has been minimized.

Copy link

John4932 commented May 27, 2019

Hi phpRajat! I noticed my WA Web has recently updated to 0.3.3321 and this is not working anymore:
Store.Chat.find("91XXXXXXXXXX@c.us").then((user) => { user.sendMessage("hello"); });
See error message below:

Screen Shot 2019-05-27 at 23 49 36

@derodevil

This comment has been minimized.

Copy link

derodevil commented May 29, 2019

Hi phpRajat! I noticed my WA Web has recently updated to 0.3.3321 and this is not working anymore:
Store.Chat.find("91XXXXXXXXXX@c.us").then((user) => { user.sendMessage("hello"); });
See error message below:

Screen Shot 2019-05-27 at 23 49 36

Did you solve this problem? I have the same problem

@dennyphilipp

This comment has been minimized.

Copy link

dennyphilipp commented May 29, 2019

Geez, I got it.
!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 }();

window.Store.SendMessage = window.mR.findModule("sendTextMsgToChat")[0].sendTextMsgToChat;
var chat = Store.Chat.models.filter(x => x.id.user === "XXXXXXX")[0];
Store.SendMessage(chat, "Hello World");

@tiagopmc

This comment has been minimized.

Copy link

tiagopmc commented May 30, 2019

@dennyphilipp If I wun your code on whatssapweb console I just get: Uncaught SyntaxError: missing ) after argument lis

@ghersonn

This comment has been minimized.

Copy link

ghersonn commented May 30, 2019

@dennyphilipp If I wun your code on whatssapweb console I just get: Uncaught SyntaxError: missing ) after argument lis

try commenting on the content of the "catch (e)"

@btursynb

This comment has been minimized.

Copy link

btursynb commented May 30, 2019

@dennyphilipp If I wun your code on whatssapweb console I just get: Uncaught SyntaxError: missing ) after argument lis

try commenting on the content of the "catch (e)"

didn't help much, could u please give a bit of more expanded advice? Or maybe share working version of the code?

@dennyphilipp

This comment has been minimized.

Copy link

dennyphilipp commented May 30, 2019

Guys, you have it another way.
@btursynb, @ghersonn, @tiagopmc
//exports modules
function getStore(modules) {
let foundCount = 0;
let neededObjects = [
{ id: "Store", conditions: (module) => (module.Chat && module.Msg) ? module : null },
{ id: "MediaCollection", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.processFiles !== undefined) ? module.default : null },
{ id: "ChatClass", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.Collection !== undefined && module.default.prototype.Collection === "Chat") ? module : null },
{ id: "MediaProcess", conditions: (module) => (module.BLOB) ? module : null },
{ id: "Wap", conditions: (module) => (module.createGroup) ? module : null },
{ id: "ServiceWorker", conditions: (module) => (module.default && module.default.killServiceWorker) ? module : null },
{ id: "State", conditions: (module) => (module.STATE && module.STREAM) ? module : null },
{ id: "WapDelete", conditions: (module) => (module.sendConversationDelete && module.sendConversationDelete.length == 2) ? module : null },
{ id: "Conn", conditions: (module) => (module.default && module.default.ref && module.default.refTTL) ? module.default : null },
{ id: "WapQuery", conditions: (module) => (module.queryExist) ? module : ((module.default && module.default.queryExist) ? module.default : null) },
{ id: "CryptoLib", conditions: (module) => (module.decryptE2EMedia) ? module : null },
{ id: "OpenChat", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.openChat) ? module.default : null },
{ id: "UserConstructor", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null },
{ id: "SendTextMsgToChat", conditions: (module) => (module.sendTextMsgToChat) ? module.sendTextMsgToChat : null },
{ id: "SendSeen", conditions: (module) => (module.sendSeen) ? module.sendSeen : null },
{ id: "MarkSeen", conditions: (module) => (module.markSeen) ? module.markSeen : null }
];
for (let idx in modules) {
if ((typeof modules[idx] === "object") && (modules[idx] !== null)) {
let first = Object.values(modules[idx])[0];
if ((typeof first === "object") && (first.exports)) {
for (let idx2 in modules[idx]) {
let module = modules(idx2);
if (!module) {
continue;
}
neededObjects.forEach((needObj) => {
if (!needObj.conditions || needObj.foundedModule)
return;
let neededModule = needObj.conditions(module);
if (neededModule !== null) {
foundCount++;
needObj.foundedModule = neededModule;
}
});
if (foundCount == neededObjects.length) {
break;
}
}

            let neededStore = neededObjects.find((needObj) => needObj.id === "Store");
            window.Store = neededStore.foundedModule ? neededStore.foundedModule : {};
            neededObjects.splice(neededObjects.indexOf(neededStore), 1);
            neededObjects.forEach((needObj) => {
                if (needObj.foundedModule) {
                    window.Store[needObj.id] = needObj.foundedModule;
                }
            });
            window.Store.ChatClass.default.prototype.sendMessage = function (e) {
                return window.Store.SendTextMsgToChat(this, ...arguments);
            }
            return window.Store;
        }
    }
}

}

webpackJsonp([], { 'parasite': (x, y, z) => getStore(z) }, ['parasite']);
//end exports modules

var chat = Store.Chat.models.filter(x => x.id.user === "XXXXXXX")[0];
Store.SendTextMsgToChat(chat, "Hello World");

@btursynb

This comment has been minimized.

Copy link

btursynb commented May 30, 2019

//exports modules
function getStore(modules) {
let foundCount = 0;
let neededObjects = [
{ id: "Store", conditions: (module) => (module.Chat && module.Msg) ? module : null },
{ id: "MediaCollection", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.processFiles !== undefined) ? module.default : null },
{ id: "ChatClass", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.Collection !== undefined && module.default.prototype.Collection === "Chat") ? module : null },
{ id: "MediaProcess", conditions: (module) => (module.BLOB) ? module : null },
{ id: "Wap", conditions: (module) => (module.createGroup) ? module : null },
{ id: "ServiceWorker", conditions: (module) => (module.default && module.default.killServiceWorker) ? module : null },
{ id: "State", conditions: (module) => (module.STATE && module.STREAM) ? module : null },
{ id: "WapDelete", conditions: (module) => (module.sendConversationDelete && module.sendConversationDelete.length == 2) ? module : null },
{ id: "Conn", conditions: (module) => (module.default && module.default.ref && module.default.refTTL) ? module.default : null },
{ id: "WapQuery", conditions: (module) => (module.queryExist) ? module : ((module.default && module.default.queryExist) ? module.default : null) },
{ id: "CryptoLib", conditions: (module) => (module.decryptE2EMedia) ? module : null },
{ id: "OpenChat", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.openChat) ? module.default : null },
{ id: "UserConstructor", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null },
{ id: "SendTextMsgToChat", conditions: (module) => (module.sendTextMsgToChat) ? module.sendTextMsgToChat : null },
{ id: "SendSeen", conditions: (module) => (module.sendSeen) ? module.sendSeen : null },
{ id: "MarkSeen", conditions: (module) => (module.markSeen) ? module.markSeen : null }
];
for (let idx in modules) {
if ((typeof modules[idx] === "object") && (modules[idx] !== null)) {
let first = Object.values(modules[idx])[0];
if ((typeof first === "object") && (first.exports)) {
for (let idx2 in modules[idx]) {
let module = modules(idx2);
if (!module) {
continue;
}
neededObjects.forEach((needObj) => {
if (!needObj.conditions || needObj.foundedModule)
return;
let neededModule = needObj.conditions(module);
if (neededModule !== null) {
foundCount++;
needObj.foundedModule = neededModule;
}
});
if (foundCount == neededObjects.length) {
break;
}
}

            let neededStore = neededObjects.find((needObj) => needObj.id === "Store");
            window.Store = neededStore.foundedModule ? neededStore.foundedModule : {};
            neededObjects.splice(neededObjects.indexOf(neededStore), 1);
            neededObjects.forEach((needObj) => {
                if (needObj.foundedModule) {
                    window.Store[needObj.id] = needObj.foundedModule;
                }
            });
            window.Store.ChatClass.default.prototype.sendMessage = function (e) {
                return window.Store.SendTextMsgToChat(this, ...arguments);
            }
            return window.Store;
        }
    }
}

}

webpackJsonp([], { 'parasite': (x, y, z) => getStore(z) }, ['parasite']);
//end exports modules

var chat = Store.Chat.models.filter(x => x.id.user === "XXXXXXX")[0];
Store.SendTextMsgToChat(chat, "Hello World");

Thank u very much!!! But I've already used the previous version. Is there any difference between these two in terms of performance?

@filipewan

This comment has been minimized.

Copy link

filipewan commented May 30, 2019

Hi everyone,

Is not working for me.

Uncaught TypeError: Cannot read property 'replace' of undefined
    at <anonymous>:29:32

The error is in this line:

		if (modules[key].exports.default) {
			if (modules[key].exports.default.Wap) {
				store_id = modules[key].id.replace(/"/g, '"');   <<-----------
			}
		}

A few days ago works just removing de replace function.... buto now dont work more!!!

Can help me?

@tinyCoder32

This comment has been minimized.

Copy link

tinyCoder32 commented May 31, 2019

for example i want to kick any new member in a group instantly when he join the group from an public link that has an special number (to example +1 country Numbers) to prevent bots spam us, how can i done this? what is the kick function @phpRajat

Here is simple code to remove particular participant from group:
const metaDataGroup = Store.GroupMetadata.get(idGroup);
const participant = metaDataGroup.participants.get(idParticipant);
metaDataGroup.participants.removeParticipants([participant]).then((ret)=>{ const check = metaDataGroup.participants.get(idParticipant); if (check === undefined){ done(true); return true; } done(false); return false; })

idGroup '0000000000-00000000@g.us'
idParticipant '000000000000@c.us'

Thanks for sharing this, how can I get the groupInviteLink please?

@phpRajat

This comment has been minimized.

Copy link
Owner Author

phpRajat commented May 31, 2019

Here is my second published script and its working fine.
https://gist.github.com/phpRajat/84c0f16f9d13f362bbd73328f5a29f84

@filipewan

This comment has been minimized.

Copy link

filipewan commented May 31, 2019

Here is my second published script and its working fine.
https://gist.github.com/phpRajat/84c0f16f9d13f362bbd73328f5a29f84

Tks so much... u are the man!!!!!

but to send image is not working more?

@gresaggr

This comment has been minimized.

Copy link

gresaggr commented May 31, 2019

If is it possible, please fix image sending.

@phpRajat

This comment has been minimized.

Copy link
Owner Author

phpRajat commented Jun 1, 2019

@filipewan and @gresaggr

I updated my whatsapp.js file which is working fine for send image and send text message.

@gresaggr

This comment has been minimized.

Copy link

gresaggr commented Jun 1, 2019

@filipewan and @gresaggr

I updated my whatsapp.js file which is working fine for send image and send text message.

Thanks! It's work perfect!

@tinyCoder32

This comment has been minimized.

Copy link

tinyCoder32 commented Jun 1, 2019

for example i want to kick any new member in a group instantly when he join the group from an public link that has an special number (to example +1 country Numbers) to prevent bots spam us, how can i done this? what is the kick function @phpRajat

Here is simple code to remove particular participant from group:
const metaDataGroup = Store.GroupMetadata.get(idGroup);
const participant = metaDataGroup.participants.get(idParticipant);
metaDataGroup.participants.removeParticipants([participant]).then((ret)=>{ const check = metaDataGroup.participants.get(idParticipant); if (check === undefined){ done(true); return true; } done(false); return false; })

idGroup '0000000000-00000000@g.us'
idParticipant '000000000000@c.us'

Hello, thank you again! is there a chance that you teach us how do we get the groupInviteLink please?

@phpRajat

This comment has been minimized.

Copy link
Owner Author

phpRajat commented Jun 1, 2019

for example i want to kick any new member in a group instantly when he join the group from an public link that has an special number (to example +1 country Numbers) to prevent bots spam us, how can i done this? what is the kick function @phpRajat

Here is simple code to remove particular participant from group:
const metaDataGroup = Store.GroupMetadata.get(idGroup);
const participant = metaDataGroup.participants.get(idParticipant);
metaDataGroup.participants.removeParticipants([participant]).then((ret)=>{ const check = metaDataGroup.participants.get(idParticipant); if (check === undefined){ done(true); return true; } done(false); return false; })
idGroup '0000000000-00000000@g.us'
idParticipant '000000000000@c.us'

Hello, thank you again! is there a chance that you teach us how do we get the groupInviteLink please?

I hope so this helps u.
Store.GroupMetadata.find("0000000000-00000000@g.us").then((x) => { console.log(x.groupInviteLink); });

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 1, 2019

Sir, can you please help me to use this script in a chrome extension?
Also can you please tell me how to check that if a mobile number is registered on whatsapp or no??

@derodevil

This comment has been minimized.

Copy link

derodevil commented Jun 1, 2019

Do you implement logout function?

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 2, 2019

How can we send a video??

@JackieMond

This comment has been minimized.

Copy link

JackieMond commented Jun 2, 2019

Hello everyone, thanks for the help so far.

I have a question, is it possible to add new contacts through the web client using the store object ?

My goal is to add a contact to the web list so i can search his Presence or status without having to add him to the phone contact list.
for my understanding it is not possible to search for a contact which is not in your contact list.
Can someone prove me wrong ?

I saw there is Store.Contact.add but i don't know the signature of the function and the parameters needed, i couldn't even monitor it since it wasn't triggered with all my tests.

I really appreciate your help

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 2, 2019

Hello @JackieMond it is possible to search the presence or the status of a user.
It can be done by following these steps :

  1. Bring back the Store function :

sigalor/whatsapp-web-reveng#45 (comment)

  1. Now fetch the status of user :

var nr = 918483900678; Store.Wap.statusFind(nr + '@c.us').then(function(r){console.log(r)})

  1. Now find the presence of user :

var nr = 918483900678; Store.Presence.find(nr + '@c.us').then(function(r){console.log(r)})

Hope this might help :)

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 2, 2019

Can somebody please help me to get list of all the phone contacts that are registered on whatsapp.
Any help will be appreciated.

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 2, 2019

@phpRajat please help!!!!!

@tinyCoder32

This comment has been minimized.

Copy link

tinyCoder32 commented Jun 2, 2019

for example i want to kick any new member in a group instantly when he join the group from an public link that has an special number (to example +1 country Numbers) to prevent bots spam us, how can i done this? what is the kick function @phpRajat

Here is simple code to remove particular participant from group:
const metaDataGroup = Store.GroupMetadata.get(idGroup);
const participant = metaDataGroup.participants.get(idParticipant);
metaDataGroup.participants.removeParticipants([participant]).then((ret)=>{ const check = metaDataGroup.participants.get(idParticipant); if (check === undefined){ done(true); return true; } done(false); return false; })
idGroup '0000000000-00000000@g.us'
idParticipant '000000000000@c.us'

Hello, thank you again! is there a chance that you teach us how do we get the groupInviteLink please?

I hope so this helps u.
Store.GroupMetadata.find("0000000000-00000000@g.us").then((x) => { console.log(x.groupInviteLink); });

Thanks, but this didn't work, it's always null, unless I open the group myself and open the link sharing window.

@JackieMond

This comment has been minimized.

Copy link

JackieMond commented Jun 3, 2019

Hello @JackieMond it is possible to search the presence or the status of a user.
It can be done by following these steps :

1. Bring back the Store function :

sigalor/whatsapp-web-reveng#45 (comment)

1. Now fetch the status of user :

var nr = 918483900678; Store.Wap.statusFind(nr + '@c.us').then(function(r){console.log(r)})

1. Now find the presence of user :

var nr = 918483900678; Store.Presence.find(nr + '@c.us').then(function(r){console.log(r)})

Hope this might help :)

The first one you indeed right.. you can search for someone Status without having him on your contact list. BUT..

for presence or profile picture you cannot.. here is the output..

  1. var nr = 918483900678; Store.Presence.find(nr + '@c.us').then(function(r){console.log(r)})
    will result
    Uncaught Error: Presence.gadd called without an id attr (id)
    at t.value (app3.c4e72dd948a018f0f168.js:2)
    at t.value (app3.c4e72dd948a018f0f168.js:2)
    at t.value (app3.c4e72dd948a018f0f168.js:2)
    at t.value (app3.c4e72dd948a018f0f168.js:2)
    at t.value (app3.c4e72dd948a018f0f168.js:2)
    at :1:16

because presence does no longer receive phone number as a parameter but whatsapp contact ID

  1. var nr = 918483900678; Store.ProfilePicThumb.find(nr + '@c.us').then(function(r){console.log(r)})
    will result
    {message: "ProfilePicThumb", name: "ModelCreateError", stack: "ModelCreateError: ProfilePicThumb↵ at t.n (http….whatsapp.com/app.7c741482fddbc756da70.js:2:6606)"

ModelCreateError because again it does something with the Model, but he cannot find the Model.

Please help.

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 3, 2019

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 3, 2019

I tried it here, perfect, I want to thank a lot of people who keep updating this code, I was desperate with the new update depreciated, now I updated everything was perfect, thank you very much ...

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 3, 2019

I think tha this script can send messages to only numbers which are in our chat list. Is it true??
Please help!!!

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 3, 2019

Yes so far yes, but I managed to send to other users but in a not very user and not very secure way, I did the following:

I changed the active user in the chat, and I changed the number information and sent the message normally, so after sending it is necessary to do a refresh on the screen, so I said, that is not very usual, anything I can help hug

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 4, 2019

@jaderesp
Can you please send me the working code??

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 4, 2019

ok:

async function sendMsg(id, text,tipo, img) {
var flag_exist = get_info_contato(id);
if (window.StoreChat === undefined){
init();
}

var Chats = window.StoreChat.Chat.models;
/* se usuário não existir na lista de batepapo ou contatos, então inserir e ativar conversa para enviar mensagem */

/* set user active to chat */
if (tipo == true) {

    if(!typeof window.StoreChat.Chat.active().user === 'undefined'){

        await simulateMouseEvents(document.querySelector('._2UaNq'), 'mousedown'); 
    }

    window.StoreChat.Chat.active().user = id; 

}

    var contact = id;
    var message = text;
    for (chat in Chats) {
        if (isNaN(chat)) {
            continue;
        };
        var temp = {};
        temp.contact = Chats[chat].__x_formattedTitle;
        temp.id = Chats[chat].__x_id;
        
        if(temp.id.user == contact  && temp.id.server == 'c.us')
        {
			if(img){
				send_media(temp.id.user + '@c.us',img,message,null,null);
			}else{
			    /* Absoleto 27-05-2019 ---> Chats[chat].sendMessage(message); */
			   await msgTexto(temp.id.user + '@c.us', message);
			}

			if(tipo == true){
				refrash_lista_bpapo();
			}

            return true
        } 

        
        
    }    

}

/* simulate mouse click - refresh list contacts html wp */
async function simulateMouseEvents(element, eventName){
var mouseEvent = document.createEvent('MouseEvents');

   mouseEvent.initEvent(eventName, true, true);
  element.dispatchEvent(mouseEvent);

}

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 4, 2019

See if this can help ...

@ghersonn

This comment has been minimized.

Copy link

ghersonn commented Jun 4, 2019

If a user sends "too many messages" (WhatsApp did not want to specify what is the limit) to people who have not saved the number of this sender in their contact lists. To avoid a suspension for this reason, the company recommends that users verify that their contacts have added their current number

How can I send bulk messages without whatsapp blocking me?

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 5, 2019

@jaderesp
what if we inserted contact information in the Store object?
i.e. in window.Store.Chat
I have created the following code :
var obj = JSON.parse(Store); str = JSON.stringify(obj); obj['Chat._index'].push({"919881589589@c.us":[{"__x_id":[{"server": "c.us", "user": "919881589589", "_serialized": "919881589589@c.us"}]}]); Store = JSON.stringify(obj);
However it is giving some errors.
Could you check it for me.

@JackieMond

This comment has been minimized.

Copy link

JackieMond commented Jun 5, 2019

@JackieMond
Then how does this works?
https://github.com/LoranKloeze/WhatsAllApp

@kraven5161 @phpRajat
Well.. its not working...
if you go inside you will see that the extension,
shows the following information:
Profile pictures
Status texts
Display names (for chat accounts)*
Online statuses (for chat accounts)*

What i need to find out is how to get
Display names and Online statuses without having them as chat accounts
or
how to add chat accounts without sending any message to the other side.

I hope its more clear now.

@btursynb

This comment has been minimized.

Copy link

btursynb commented Jun 5, 2019

@jaderesp @phpRajat @JackieMond
Hi, I've built a chat application that uses this code + some python code + selenium + geckodriver. And have an issue, that my firefox where web.whatsapp is open freezes when working for a long time period (a few days), and bot stops working. The workload is about 100-200 new chats every day. I archive them on a regular basis (50 chats every 6 hours). Could you please recommend me any actions to improve performance of the application? p.s. I do not send spam, working only with contacts that initiated chat first.

@ghersonn

This comment has been minimized.

Copy link

ghersonn commented Jun 5, 2019

How can I send a broadcast?

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 5, 2019

Anyone ever tried unpacking this addContact function to see how it works, would it be to add contacts yourself?

whats inplement has params add????

window.StoreChat.Wap.addContact

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 5, 2019

message sent to a strange contact ...

1º step:

window.open('https://web.whatsapp.com/send?l=pt_BR&phone=5511999042948&text=good bye.', '_parent');

he will do the refrash on the screen and ask to send the message, however it is not necessary to send by clicking on the button from the moment that is made the execution of this api the contact is already in his list there only to send via script like in step 2:

2º step:

sendMsg("5511999042948","good night...");

ready message sent to a strange contact ...

I'm sending this discovery not to celebrate, but to give an understanding of how we can add the contact via code if someone finds out please send it to hug us all

@AlexDiSomma

This comment has been minimized.

Copy link

AlexDiSomma commented Jun 8, 2019

Oh my GOD! You're a Genious!!!
Could you help me with a problem? I try to launch it via eclipse with a java swing program trought the instruction
((JavascriptExecutor) driver).executeScript("script code"));

but it returns an error at this point:

var Store = {};

function init() {
window.Store = _requireById(store_id).default;
window.Store.sendTextMsgToChat = _requireById(chat_id).sendTextMsgToChat;
console.log("Store is ready");
window.Store.Chat.find("91xxxxxxxxxx@c.us").then((user) => { window.Store.sendTextMsgToChat(user, "hellao"); });
}

The error Say "unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected token var"

Do you know how to fix it?

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 9, 2019

where are you filling the store_id variable? one of its variables has not been defined and the Var Store or window.Store? I think you always have to use a single way

On eclipse, I use the same idea only that I use cefSharp with C # or VB.net, but the idea is the same to excuse the script inside a browser itself ... hug

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 9, 2019

Oh, check also the format of the string that you are executing in the browser, it is very important to send a format in order to give an error at the beginning of the script

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 12, 2019

@jaderesp
I think that if we are able to insert data into Store.Chat._index then we could be able to send a message to a strange contact.
We just have to insert :
{"919881589589@c.us":[{"__x_id":[{"server": "c.us", "user": "919881589589", "_serialized": "919881589589@c.us"}]}]}
Please help me in this matter.
Any help will be appreciated.

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 12, 2019

I had the same perception, and I did the test and managed to send, but I added the user to the active contact like this:

note: this function makes the desired user active in chatpapo so it is possible to send message to unknown user, but need to change the status of serviceWorker :( to work

function set_user_receptive(num_){

var indice_ = window.StoreChat.Chat.models["length"];

var contact_formed = num_ + "@c.us";


/* fazer uma copia do indice anterior */
window.StoreChat.Chat.models[indice_] = window.StoreChat.Chat.models[(indice_ - 1)];
window.StoreChat.Chat.models[indice_].__x_id["user"] = num_;
window.StoreChat.Chat.models[indice_].__x_id["_serialized"] = contact_formed;

//_.extend([{"__x_id":[{"server": "c.us", "user": num_, "_serialized": contact_formed}]}]);

}

now it only works if I go in the google chrome tools and change the status of the service worker to offline, then the user appears in the list and I can send without problems if we can find that solution voilah ...

image

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 12, 2019

If someone can solve this problem, then yes ...

@MrSwagger1337

This comment has been minimized.

Copy link

MrSwagger1337 commented Jun 12, 2019

can we delete all chats and clear whatsapp by store?

@MrSwagger1337

This comment has been minimized.

Copy link

MrSwagger1337 commented Jun 12, 2019

like : -- but its not work anymore
Store.Chat.models.forEach(function(m) {
m.sendDelete();
});

@btursynb

This comment has been minimized.

Copy link

btursynb commented Jun 13, 2019

Do anybody has issues with stability of Chrome/FF when using it with Selenium? Mine freezes from time to time.

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 13, 2019

Does anyone have a function to send a message to the existing contact but that is not in the conversation list?

@MrSwagger1337

This comment has been minimized.

Copy link

MrSwagger1337 commented Jun 13, 2019

Does anyone have a function to send a message to the existing contact but that is not in the conversation list?

i am, but you must use selenium with it

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 15, 2019

@jaderesp
Insted of sending whatsapp messages using web.whatsapp.com, using YOWSUP https://github.com/tgalal/yowsup/ is also a good alternative.

@pablocorezzola

This comment has been minimized.

Copy link

pablocorezzola commented Jun 15, 2019

This project is also very good. It's called "Sulla." https://github.com/danielcardeenas/sulla.

What is really important is in "https://github.com/danielcardeenas/sulla/blob/master/src/lib/wapi.js". I was served the window.WAPI.sendMessageToID ("number@c.us", "text") function to send messages to unknown numbers.

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 15, 2019

@pablocorezzola
But how to execute the function??
Can you please help me in this case.

@pablocorezzola

This comment has been minimized.

Copy link

pablocorezzola commented Jun 15, 2019

@pablocorezzola
But how to execute the function??
Can you please help me in this case.

Too easy.
1: just copy the entire contents of the wapi.js file into your browser's console.
2: use the function window.WAPI.sendMessageToID ("number@c.us", "text") to send messages

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 15, 2019

@pablocorezzola
I have already followed the same steps. But the following error occured :
Uncaught TypeError: window.Store.UserConstructor is not a constructor at Object.window.WAPI.sendMessageToID (<anonymous>:706:62) at <anonymous>:1:13
Please check it for me.

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 15, 2019

@pablocorezzola
top top top, everything ready works very well, very good too ... thank you guys got right here for me at least what I needed was sending it to contacts that were not on the chat list or who had an active conversation, I've been working here parabens, good work dear friend @pablocorezzola

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 15, 2019

@pablocorezzola
very simple guy, just run the complete file, and call the functions by throwing the parameters you want to see:

image

@pablocorezzola

This comment has been minimized.

Copy link

pablocorezzola commented Jun 15, 2019

@Manjit2003

This is an example of how you can use.

what

@pablocorezzola

This comment has been minimized.

Copy link

pablocorezzola commented Jun 15, 2019

@jaderesp

Yes sir. Very simple

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 15, 2019

@Manjit2003
congratulations its is good works, congratulations alls
image

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 15, 2019

I would like to validate with you if this function that I mounted as I saw in the above files indicated by friends.
the function to check if the number is wp see and give me a return ok big hug ...

`
/* add in : 15-06-2019 - verif if contact is wp /
/
verificar se contato é wp */
async function verifIsContactWp(id){

/* window.getContact = (id) => {
        return Store.WapQuery.queryExist(id);
    } */
var result = window.getContact(id).then(contact => {
    if (contact.status === 404){

        return false;

    }else{

        return true;
            
    }
});

return result;

}`

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 16, 2019

@jaderesp
@pablocorezzola

How can we chek using this that we check using this that weather a phone number is registered on whatsapp or not??
I am currently using the following query :

window.WAPI.checkNumberStatus("919881589589@c.us")

However it is always returning True.
Somebody please help.

@derodevil

This comment has been minimized.

Copy link

derodevil commented Jun 17, 2019

@Manjit2003

This is an example of how you can use.

what

Why did it return false while the message was successfully sent?

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 17, 2019

Could someone send a photo message to unknown contact?

@Luizcarvalho2006

This comment has been minimized.

Copy link

Luizcarvalho2006 commented Jun 20, 2019

@jaderesp
You can first send a text message, and latter he will be in your Store.Contact or Store.Chat.

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 21, 2019

@jaderesp
@Luizcarvalho2006

window.WAPI.sendImage("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwBwAFAgH9XSO6wwAAAABJRU5ErkJggg==" , "91XXXXXXXXXX@c.us", "Test.png", "Hello")

Would help to send photo message (Image) to a unknown contact.

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 21, 2019

@jaderesp
@Luizcarvalho2006
@derodevil

Can someone guide me to check that if a phone number is registered on whatsapp or not???

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 22, 2019

@Manjit2003
solutions temp

@jaderesp @Luizcarvalho2006 @derodevil
Can someone guide me to check that if a phone number is registered on whatsapp or not???

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jun 22, 2019

@jaderesp @Luizcarvalho2006

window.WAPI.sendImage("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwBwAFAgH9XSO6wwAAAABJRU5ErkJggg==" , "91XXXXXXXXXX@c.us", "Test.png", "Hello")

Would help to send photo message (Image) to a unknown contact.

I tried to use this function to send message to strange contacts after sending text message, it sends the image but the contact does not receive, it creates a fake contact but the message does not reach the recipient

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 22, 2019

@@jaderesp
I don't know why the problem is occuring in your case but you can check that you are not blocked by the recipient. As in my case i am successfully able to send images but still i am not able to send video messages
Also please help me to check that if a phone number is registered on whatsapp or not.

@derodevil

This comment has been minimized.

Copy link

derodevil commented Jun 22, 2019

I have 19 whatsapp groups. I try this code window.Store.Chat.filter((chat) => chat.isGroup && chat.groupMetadata.participants.models.length == 0) and this returns 13 groups where the paticipants models are empty. Does anynone know how to reload all participants in each group?

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 23, 2019

@derodevil
Actully i cant give you the complete code but i think this might help :
Step 1
Get all group ID's by:
WAPI.getAllGroups()
This will give you an list of groups.
Step 2
Enumerate the participants by:
WAPI.getGroupParticipantIDs("XXXXXXXXXXXX-XXXXXXXXXX@g.us")
Hope this might help.
Regards.

@derodevil

This comment has been minimized.

Copy link

derodevil commented Jun 23, 2019

@Manjit2003 thanks so much, it works like a charm.

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 25, 2019

Someone can please help me as i want to use WAPI in a chrome extension.
Whenever i run the chrome extension it is giving the following error:
Uncaught ReferenceError: webpackJsonp is not defined
It is because webpackJsonp is a function provided by whatsapp.
I have tried to run it using content script as well as background script but stil it dosent works.
Someone please help in this matter.
@derodevil, @jaderesp, @Luizcarvalho2006 & @pablocorezzola Pleas help as i have great expectations from you.
Any help will be appreciated.

@btursynb

This comment has been minimized.

Copy link

btursynb commented Jun 25, 2019

Someone can please help me as i want to use WAPI in a chrome extension.
Whenever i run the chrome extension it is giving the following error:
Uncaught ReferenceError: webpackJsonp is not defined
It is because webpackJsonp is a function provided by whatsapp.
I have tried to run it using content script as well as background script but stil it dosent works.
Someone please help in this matter.
@derodevil, @jaderesp, @Luizcarvalho2006 & @pablocorezzola Pleas help as i have great expectations from you.
Any help will be appreciated.

Hi, u may look into this project: https://github.com/cprcrack/WAToolkit

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jun 30, 2019

Whatsapp Has now launched its official API
However the API is very difficult to implement. I mean that there are no easy functions such as message.send().
So is here anyone intrested in creating a library for that API.
If intrested then contact me on +91 8483900678 My name is Manjit Pardeshi.
We can make a library which does not blocks the whatsapp number as it is using the official API.

@fabianomichels

This comment has been minimized.

Copy link

fabianomichels commented Jul 2, 2019

Is possible to get the 'last seen' value from some number that is not my contact?

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Jul 3, 2019

Does anyone have the function that returns the base64 or any other QRCODE format to connect whatsapp? thank you, hug

@yskristiawan

This comment has been minimized.

Copy link

yskristiawan commented Jul 21, 2019

Does anyone have the function that returns the base64 or any other QRCODE format to connect whatsapp? thank you, hug

I use the HTML. Get the content of '<img alt="Scan me!" '. Quite easy...

@yskristiawan

This comment has been minimized.

Copy link

yskristiawan commented Jul 21, 2019

Anybody solve the send message and message + image to new phone number?

@yskristiawan

This comment has been minimized.

Copy link

yskristiawan commented Jul 21, 2019

Anybody solve the send message and message + image to new phone number?

Finally I am using https://github.com/danielcardeenas/sulla/blob/master/src/lib/wapi.js. Works well with sending image and sending to new phone number.

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Jul 24, 2019

Could anyone help me in sending video message through WAPI or any other solution??

@mertxkaan

This comment has been minimized.

Copy link

mertxkaan commented Jul 30, 2019

Someone can please help me as i want to use WAPI in a chrome extension.
Whenever i run the chrome extension it is giving the following error:
Uncaught ReferenceError: webpackJsonp is not defined
It is because webpackJsonp is a function provided by whatsapp.
I have tried to run it using content script as well as background script but stil it dosent works.
Someone please help in this matter.
@derodevil, @jaderesp, @Luizcarvalho2006 & @pablocorezzola Pleas help as i have great expectations from you.
Any help will be appreciated.

@Manjit2003
(First of all, I am not an expert, just interested in coding and trying to find solutions;)
I think because when you paste the code to console, whatsapp code was ready to use its functions, so it is successful. In your extension, you can use setTimeout() in the beginning of Wapi, to pass some seconds(5-10?) and give the code some time to load. Like,

if (!window.Store) { setTimeout(function () { function getStore(modules) {........}, 7000); }

👍

@ianspektor

This comment has been minimized.

Copy link

ianspektor commented Aug 15, 2019

Has anybody had trouble sending images? Code was working fine, but as of today it stopped working for me.

I've had no luck trying to debug the code since I am very unfamiliar with it, but I am somewhat sure that the variable createFromData_id isnt being initialized like it should.

Any help would be more than appreciated!

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Aug 15, 2019

I have the same problem, code stopped sending message with image, any solution we put here, as soon as we find

@dennyphilipp

This comment has been minimized.

Copy link

dennyphilipp commented Aug 15, 2019

This code ok, for send images @ianspektor, @jaderesp

function Base64ImageToFile(b64Data, filename) {
var arr = b64Data.split(',');
var mime = arr[0].match(/:(.*?);/)[1];
var bstr = atob(arr[1]);
var n = bstr.length;
var u8arr = new Uint8Array(n);

    while (n--) {
        u8arr[n] = bstr.charCodeAt(n);
    }

    return new File([u8arr], filename, { type: mime });
};

function EnviarImagem(imgBase64, chatid, filename, caption) {
var idUser = new window.Store.UserConstructor(chatid, { intentionallyUsePrivateConstructor: true });
return Store.Chat.find(idUser).then((chat) => {
var mediaBlob = Base64ImageToFile(imgBase64, filename);
var mc = new Store.MediaCollection();
mc.processFiles([mediaBlob], chat, 1).then(() => {
var media = mc.models[0];
media.sendToChat(chat, { caption: caption });
});
});
};

//pdf data:application/pdf;base64,JVBERi0xLj.....
//image data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA......

EnviarImagem("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA......", "XXXXXXXXX@c.us", "test", "test");

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Aug 18, 2019

This code works :
WAPI.sendImage("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==", "91XXXXXXXXXX@c.us", "helo.png", "hello")

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Aug 19, 2019

This code works :
WAPI.sendImage("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==", "91XXXXXXXXXX@c.us", "helo.png", "hello")

the previous function that stopped working has been replaced by this one, but it doesn't send the messages in the right sequence, does anyone know what criteria this function uses to organize the messages being sent?
I also think that may be why every time he sends creates a new instance to send, the correct would be that to send to existing contacts use the existing whatsapp store ... can someone help in this regard?

@mauriciog98

This comment has been minimized.

Copy link

mauriciog98 commented Aug 23, 2019

Has someone any solution? I have the same problem

@13banda

This comment has been minimized.

Copy link

13banda commented Aug 28, 2019

is their any whatsapp update. uniqueId is undefined after inject the store script

@13banda

This comment has been minimized.

Copy link

13banda commented Aug 28, 2019

Error while inject
image

@dennyphilipp

This comment has been minimized.

Copy link

dennyphilipp commented Aug 28, 2019

Error while inject
image

Try this export modules
if (!window.Store) {
(function () {
function getStore(modules) {
let foundCount = 0;
let neededObjects = [
{ id: "Store", conditions: (module) => (module.Chat && module.Msg) ? module : null },
{ id: "MediaCollection", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.processFiles !== undefined) ? module.default : null },
{ id: "ChatClass", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.Collection !== undefined && module.default.prototype.Collection === "Chat") ? module : null },
{ id: "MediaProcess", conditions: (module) => (module.BLOB) ? module : null },
{ id: "Wap", conditions: (module) => (module.createGroup) ? module : null },
{ id: "ServiceWorker", conditions: (module) => (module.default && module.default.killServiceWorker) ? module : null },
{ id: "State", conditions: (module) => (module.STATE && module.STREAM) ? module : null },
{ id: "WapDelete", conditions: (module) => (module.sendConversationDelete && module.sendConversationDelete.length == 2) ? module : null },
{ id: "Conn", conditions: (module) => (module.default && module.default.ref && module.default.refTTL) ? module.default : null },
{ id: "WapQuery", conditions: (module) => (module.queryExist) ? module : ((module.default && module.default.queryExist) ? module.default : null) },
{ id: "CryptoLib", conditions: (module) => (module.decryptE2EMedia) ? module : null },
{ id: "OpenChat", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.openChat) ? module.default : null },
{ id: "UserConstructor", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null },
{ id: "SendTextMsgToChat", conditions: (module) => (module.sendTextMsgToChat) ? module.sendTextMsgToChat : null },
{ id: "SendSeen", conditions: (module) => (module.sendSeen) ? module.sendSeen : null },
{ id: "sendDelete", conditions: (module) => (module.sendDelete) ? module.sendDelete : null }
];
for (let idx in modules) {
if ((typeof modules[idx] === "object") && (modules[idx] !== null)) {
let first = Object.values(modules[idx])[0];
if ((typeof first === "object") && (first.exports)) {
for (let idx2 in modules[idx]) {
let module = modules(idx2);
if (!module) {
continue;
}
neededObjects.forEach((needObj) => {
if (!needObj.conditions || needObj.foundedModule)
return;
let neededModule = needObj.conditions(module);
if (neededModule !== null) {
foundCount++;
needObj.foundedModule = neededModule;
}
});
if (foundCount == neededObjects.length) {
break;
}
}

                    let neededStore = neededObjects.find((needObj) => needObj.id === "Store");
                    window.Store = neededStore.foundedModule ? neededStore.foundedModule : {};
                    neededObjects.splice(neededObjects.indexOf(neededStore), 1);
                    neededObjects.forEach((needObj) => {
                        if (needObj.foundedModule) {
                            window.Store[needObj.id] = needObj.foundedModule;
                        }
                    });
                    window.Store.ChatClass.default.prototype.sendMessage = function (e) {
                        return window.Store.SendTextMsgToChat(this, ...arguments);
                    }
                    return window.Store;
                }
            }
        }
    }

    webpackJsonp([], { 'parasite': (x, y, z) => getStore(z) }, ['parasite']);
})();

}

@kaledhananjay

This comment has been minimized.

Copy link

kaledhananjay commented Aug 29, 2019

Hello

Today we getting below error when trying to send message

VM31:440 Uncaught ReferenceError: _module is not defined
at init (:440:491)
at :440:858

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Aug 29, 2019

Hello

Today we getting below error when trying to send message

VM31:440 Uncaught ReferenceError: _module is not defined
at init (:440:491)
at :440:858

friend, the palative solution at the moment is the same as the friend posted, use the module started by window.WAPI which is window.Store and either use it or make a copy of it window.StoreChat = window.Store

makes an adaptation to your system, for now we have no other method ready ...

@13banda

This comment has been minimized.

Copy link

13banda commented Aug 29, 2019

This is also working

// Get module by ID found from the function above
function _requireById(id) {
	return webpackJsonp([], null, [id]);
}
var Store = {};
Store = _requireById("bhggeigghg").default;
Store.sendTextMsgToChat = _requireById("dbbhhgjjbg").sendTextMsgToChat```
@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Aug 30, 2019

I try to execute the file code in the browser console: https://github.com/danielcardeenas/sulla/blob/master/src/lib/wapi.js

this error message appears: Uncaught TypeError: Cannot read property 'Msg' of undefined
at :1077:14

what am I doing wrong?

@kaledhananjay

This comment has been minimized.

Copy link

kaledhananjay commented Aug 30, 2019

@13banda : Thanks, I can confirm that message sending works with what you described but how can we send images? Please help.

@13banda

This comment has been minimized.

Copy link

13banda commented Aug 30, 2019

@kaledhananjay There is two types. can you tell me how you want to send Images ?

@kaledhananjay

This comment has been minimized.

Copy link

kaledhananjay commented Aug 30, 2019

@13banda : Any one way is okay. Please share either of the methods or both if possible to send any attachment.

@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Aug 30, 2019

Thanks, I managed to make some functions work. But unfortunately sending messages and files are not working, for sending messages displays the following error:

"Store.sendTextMsgToChat is not a function
     at Store.Chat.find.then (about: blank: 89)
     at ie (app.5b1c3ef6635fc7ae23c7.js: 2)
     at MutationObserver.re (app.5b1c3ef6635fc7ae23c7.js: 2) "

And for the files:

"about:blank:151 TypeError: Cannot read property 'createFromData' of undefined
at Store.Chat.find.then (about:blank:135)
at ie (app.5b1c3ef6635fc7ae23c7.js:2)
at MutationObserver.re (app.5b1c3ef6635fc7ae23c7.js:2)"

Can someone help me please?

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Aug 30, 2019

guys, anyone here, know how to forward the message via whatsapp web code?

would be a great solution and save money on consecutive image messaging

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Aug 30, 2019

Thanks, I managed to make some functions work. But unfortunately sending messages and files are not working, for sending messages displays the following error:

"Store.sendTextMsgToChat is not a function
at Store.Chat.find.then (about: blank: 89)
at ie (app.5b1c3ef6635fc7ae23c7.js: 2)
at MutationObserver.re (app.5b1c3ef6635fc7ae23c7.js: 2) "

And for the files:

"about:blank:151 TypeError: Cannot read property 'createFromData' of undefined
at Store.Chat.find.then (about:blank:135)
at ie (app.5b1c3ef6635fc7ae23c7.js:2)
at MutationObserver.re (app.5b1c3ef6635fc7ae23c7.js:2)"

Can someone help me please?

Hello Douglas, man I had the same problem here, but I used the function in Sulla. and I called the image upload function so I can solve the problem temporarily see:

This project is also very good. It's called "Sulla." https://github.com/danielcardeenas/sulla.

/ * UPDATED DAY 15/09/2019 AT 15: 0 * /
async function send_media (chatid, imgBase64, caption, msg_id, done) {

var data = new Date ();
var filename = data.getMilliseconds () + '_jmsofts';

return window.Store.Chat.find (chatid) .then ((chat) => {
    var mediaBlob = window.WAPI.base64ImageToFile (imgBase64, filename);
    var mc = new Store.MediaCollection ();
    mc.processFiles ([mediaBlob], chat, 1) .then (() => {
        var media = mc.models [0];
        media.sendToChat (chat, {caption: caption});
        if (done! == undefined) done (true);
    });
});

};

@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Aug 30, 2019

Ok, I will try to make these changes. Thanks jaderesp.

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Sep 1, 2019

error:
window.WAPI.sendMessage(in promise) TypeError: Store.MediaCollection is not a constructor

window.WAPI.sendImage = function (imgBase64, chatid, filename, caption, done) {
//var idUser = new window.Store.UserConstructor(chatid);
var idUser = new window.Store.UserConstructor(chatid, { intentionallyUsePrivateConstructor: true });
// create new chat
return Store.Chat.find(idUser).then((chat) => {
var mediaBlob = window.WAPI.base64ImageToFile(imgBase64, filename);
var mc = new Store.MediaCollection();
mc.processFiles([mediaBlob], chat, 1).then(() => {
var media = mc.models[0];
media.sendToChat(chat, { caption: caption });
if (done !== undefined) done(true);
});
});
}

@kasino64

This comment has been minimized.

Copy link

kasino64 commented Sep 12, 2019

script stop to work, can you help me?

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Sep 14, 2019

@kasino64 can you give the console output so we can look into the matter.

@gresaggr

This comment has been minimized.

Copy link

gresaggr commented Sep 15, 2019

Hello.
How can I send message to group?

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Sep 16, 2019

verify send for :
551699988776@c.us ---> user
551699988776@g.us

example:
temp1

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Sep 16, 2019

for verify user["server"] in:

function get_grup(){
var conversas = window.StoreChat.Chat.models;
for(var i=0; i < conversas.length;i++){
if(conversas[i].__x_id["server"] !== "c.us"){
console.log("sendind for group 👉👉 " + conversas[i].__x_id["server"]);
}
}

}

@derodevil

This comment has been minimized.

Copy link

derodevil commented Sep 27, 2019

Store.Chat is undefined and function sendTextMsgToChat is not working anymore if called before QR code scanning. The only way to make it work is to excute after scanning

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Sep 28, 2019

@jaderesp
This code to fetch groups would be much easier.

function get_grup() { data = WAPI.getAllGroups(); for (i = 0; i < data.length; i++) { console.log(data[i].__x_id._serialized + " : " + data[i].__x_formattedTitle) };}

@alvaritus

This comment has been minimized.

Copy link

alvaritus commented Sep 30, 2019

Hi, I have this code -> message.__x_mediaData.__x_renderableUrl to download received images messages but doesn't work anymore. Can you help me to get this work again?

Thank you in advance

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Sep 30, 2019

@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Oct 1, 2019

Does anyone know of any code to get the WhatsApp profile image from a number connected to WhatsApp Web?

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Oct 1, 2019

@DouglasAugustoDGS
Try WAPI.getProfilePicFromId('91xxxxxxxxxx@c.us')

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 1, 2019

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 5, 2019

How to send images?

up

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Oct 5, 2019

window.WAPI.sendImage = function (imgBase64, chatid, filename, caption, done) { //var idUser = new window.Store.UserConstructor(chatid); var idUser = new window.Store.UserConstructor(chatid, { intentionallyUsePrivateConstructor: true }); // create new chat return Store.Chat.find(idUser).then((chat) => { var mediaBlob = window.WAPI.base64ImageToFile(imgBase64, filename); var mc = new Store.MediaCollection(); mc.processFiles([mediaBlob], chat, 1).then(() => { var media = mc.models[0]; media.sendToChat(chat, { caption: caption }); if (done !== undefined) done(true); }); }); }

@alvaritus

This comment has been minimized.

Copy link

alvaritus commented Oct 7, 2019

How can I download a received image? Thanks

@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Oct 7, 2019

I was able to get the WhatsApp profile image URL, but only your profile or any contact you have a conversation with, if anyone needs it you can use this code:

function WMBSP_GETPROFILEPICTUREFROMID (id) {

var urlImage = "";

urlImage = Store.ProfilePicThumb.index [id] ._ x_eurl;

return urlImage;

}

function WMBSP_GETPROFILEPICTUREFROMCONTACT (id) {

var urlImageContact = "";

urlImage = Store.Contact.index [id] ._ x_profilePicThumb .__ x_eurl;

return urlImageContact;

}

@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Oct 8, 2019

Does anyone know how to extract all added WhatsApp contacts?

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Oct 8, 2019

This one:
`function get_contatos(){

		  var contats = window.StoreChat.Contact.models; 
		  var lst_contatos = '';
		  var tp='';
		  $.each(contats, function(index, value){
		  if(contats[index].__x_id['server'] == 'g.us'){ 
		  tp = 'Grupo'; 
		  
		  }else if(contats[index].__x_id['server'] == 'c.us'){
		  
				tp = 'Contato';
		
		  } 
		   lst_contatos +=' '+ tp + ',' + contats[index].__x_displayName + ',' + contats[index].__x_id['user'] + '|';  
		  
		  }); 
		  return lst_contatos; 
		  
      }`
@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Oct 8, 2019

Thanks a lot :), I managed to extract the contacts and their names, I used this code:

function getAllContacts () {

var contacts = Store.Contact._models;

for (var i = 0; i <contacts .length; i ++) {

var number = "";
var name = "";

if (contacts [i] .__ x_id.user! == "") {
number = contacts [i] .__ x_id.user;
name = contacts [i] .__ x_formattedName;
}

if (contacts [i] .__ x_id.user.includes ("-")) {
var contactClean = contacts [i] .__ x_id.user.split ("-");
number = contactClean [0];
name = contacts [i] .__ x_formattedName;
}

console.log ("Extracting contact from number:" + number);
console.log ("Name:" + name);

}

}

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Oct 8, 2019

Thanks a lot :), I managed to extract the contacts and their names, I used this code:

function getAllContacts () {

var contacts = Store.Contact._models;

for (var i = 0; i <contacts .length; i ++) {

var number = "";
var name = "";

if (contacts [i] .__ x_id.user! == "") {
number = contacts [i] .__ x_id.user;
name = contacts [i] .__ x_formattedName;
}

if (contacts [i] .__ x_id.user.includes ("-")) {
var contactClean = contacts [i] .__ x_id.user.split ("-");
number = contactClean [0];
name = contacts [i] .__ x_formattedName;
}

console.log ("Extracting contact from number:" + number);
console.log ("Name:" + name);

}

}

this function you used only brings the contacts from active conversations, not all existing contacts on your whatsapp, the function I sent up brings everything down to the oldest

@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Oct 8, 2019

From what I tested I was able to extract contacts even from groups and numbers not added.

One question, is there a way to make a function to read messages automatically?

@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Oct 9, 2019

The WhatsApp has recently updated its code, and the Store object is "undefined" here, has anyone found a solution?

@bvodola

This comment has been minimized.

Copy link

bvodola commented Oct 9, 2019

The WhatsApp has recently updated its code, and the Store object is "undefined" here, has anyone found a solution?

@DouglasAugustoDGS use this: https://gist.github.com/phpRajat/a6422922efae32914f4dbd1082f3f412#gistcomment-2930878

@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Oct 9, 2019

Thanks. I was able to use the Store, but I couldn't find Store.Wapp and Store.Conn, can anyone help me?

@dennyphilipp

This comment has been minimized.

Copy link

dennyphilipp commented Oct 9, 2019

Thanks. I was able to use the Store, but I couldn't find Store.Wapp and Store.Conn, can anyone help me?

https://gist.github.com/phpRajat/a6422922efae32914f4dbd1082f3f412#gistcomment-3010898

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 10, 2019

Whatsapp updated and stopped receiving messages, I can only send.

Uncaught TypeError: Cannot read property 'Conn' of null

Can someone help me?

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 10, 2019

How do I listen to incoming messages?

@apautov

This comment has been minimized.

Copy link

apautov commented Oct 10, 2019

This is how:

function _requireById(id) {
return webpackJsonp([], null, [id]);
}

window.Store = _requireById('bhggeigghg').default;

@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Oct 10, 2019

Is there any way to be able to export modules that have Store.Conn and Store.Wap using the phprajat method?

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 10, 2019

function _requireById(id) {
return webpackJsonp([], null, [id]);
}

window.Store = _requireById('bhggeigghg').default;

55/5000
Could you record a demo video of this? I ran your code, but I don't find the new messages. Thanks.

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Oct 10, 2019

Guys the all-in-one solution to yout porblems is using the WAPI functions.

Step 1 : Copy the code from this link https://raw.githubusercontent.com/mukulhase/WebWhatsapp-Wrapper/master/webwhatsapi/js/wapi.js an paste it in the console of web.whatsapp.com.

Step 2 : You are already done!

To send text message : WAPI.sendMessageToID('918483900678@c.us', 'hi sent from python')
To get unread message : WAPI.getUnreadMessages(includeMe="True", includeNotifications="True", use_unread_count="True") This will give you an array of unread messages.

I hope that it will help you.

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 10, 2019

Guys the all-in-one solution to yout porblems is using the WAPI functions.

Step 1 : Copy the code from this link https://raw.githubusercontent.com/mukulhase/WebWhatsapp-Wrapper/master/webwhatsapi/js/wapi.js an paste it in the console of web.whatsapp.com.

Step 2 : You are already done!

To send text message : WAPI.sendMessageToID('918483900678@c.us', 'hi sent from python')
To get unread message : WAPI.getUnreadMessages(includeMe="True", includeNotifications="True", use_unread_count="True") This will give you an array of unread messages.

I hope that it will help you.

Thanks! it works!

@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Oct 10, 2019

WAPI worked, but all Store functions only appear if you start this Store after the number is connected to WhatsApp Web, otherwise only some functions appear.

How to solve it?

Before reading QR Code
After connection

@dennyphilipp

This comment has been minimized.

Copy link

dennyphilipp commented Oct 11, 2019

WAPI worked, but all Store functions only appear if you start this Store after the number is connected to WhatsApp Web, otherwise only some functions appear.

How to solve it?

Before reading QR Code
After connection

So far, only Store is visible only after reading qrcode on mobile

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 12, 2019

Hello! How do I check if whatsapp status is authenticated or not?

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 12, 2019

Up please

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 12, 2019

Guys the all-in-one solution to yout porblems is using the WAPI functions.

Step 1 : Copy the code from this link https://raw.githubusercontent.com/mukulhase/WebWhatsapp-Wrapper/master/webwhatsapi/js/wapi.js an paste it in the console of web.whatsapp.com.

Step 2 : You are already done!

To send text message : WAPI.sendMessageToID('918483900678@c.us', 'hi sent from python')
To get unread message : WAPI.getUnreadMessages(includeMe="True", includeNotifications="True", use_unread_count="True") This will give you an array of unread messages.

I hope that it will help you.

How do I get the console log? Is it possible to generate a JSON return file of the new messages?

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Oct 12, 2019

To check if the user is logged in just use :
WAPI.isLoggedIn()

And to gte JSON file of new messages you will have to put
WAPI.getUnreadMessages(includeMe="True", includeNotifications="True", use_unread_count="True")
in a FOR-LOOP.

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 12, 2019

To check if the user is logged in just use :
WAPI.isLoggedIn()

And to gte JSON file of new messages you will have to put
WAPI.getUnreadMessages(includeMe="True", includeNotifications="True", use_unread_count="True")
in a FOR-LOOP.

Ok. Have any idea how to make this FOR-LOOP save JSON to an external file automatically? I need to treat JSON in DELPHI language for example. I use the CEF chromium. Thanks.

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 12, 2019

Is it possible to export the console log to be manipulated by other programming languages?

@Manjit2003

This comment has been minimized.

Copy link

Manjit2003 commented Oct 13, 2019

Yes you can use
https://github.com/mukulhase/WebWhatsapp-Wrapper
it is in python.

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 13, 2019

Yes you can use
https://github.com/mukulhase/WebWhatsapp-Wrapper
it is in python.

Thanks but it didn't help me much. I use TChromium CEF4Delphi to inject the JS and send the messages. I need to get the console log to create a JSON and handle the messages received by whatsapp.

Can you help me? appreciate

@apautov

This comment has been minimized.

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 13, 2019

What you need is to create an extension. See this:
https://stackoverflow.com/questions/24647762/dcef3-delphi-chromium-embedded-communication-between-javascript-and-applicat

I could not implement. I use the latest version of Delphi. Can you help me with something? thanks.

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 14, 2019

What you need is to create an extension. See this:
https://stackoverflow.com/questions/24647762/dcef3-delphi-chromium-embedded-communication-between-javascript-and-applicat

Is there any example of this working? I tested it here but it doesn't work.

I need help getting the javascript return from the TChromium console.

Someone please?

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Oct 15, 2019

hello,

I use an application with an idea similar to yours, but I use VB.NET with cefsharp for chromium, and I use javascript to sync any function I synchronize, and inject the functions in wp web through the browser function.

browser.ExecuteScriptAsync(" sendMensage('551698877738','😎Hello'); ");

cefsharp chromium https://cefsharp.github.io/

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 15, 2019

The problem is not send.

I cannot handle message receipts.

@jaderesp

This comment has been minimized.

Copy link

jaderesp commented Oct 15, 2019

The problem is not send.

I cannot handle message receipts.

Just as simple, the function that executes the script if there is return value it also returns me, then just put in the function return the message received or any other information of the message you want to return in the system script.

`
dim script = " get_newMessages(); "
dim result = browser.EvaluateScriptAsync(script)
if result then

  msgBox("Is Message: " & result);

end if
`

@AlexDiSomma

This comment has been minimized.

Copy link

AlexDiSomma commented Oct 16, 2019

Hello guys, I want to export an Array into my java program using the command "WAPI.getAllContacts()" in order to create a phonebook in csv.
It's possibile? Someone can help me??
Thanks

@apautov

This comment has been minimized.

Copy link

apautov commented Oct 17, 2019

Guys, something has been changed in the logics of attachments downloading. For instance, when image is received now MSG.mediaBlob === null.
Before the following way of obtaining media data worked:

MSG._mediaObject.downloadStage = 'INIT';
MSG.downloadMedia();

And when MSG._mediaObject.downloadStage === 'RESOLVED' it meant that downloading is complete and it was possible to work with MSG._mediaObject.mediaBlob that stored file contents. But now it's null.

Do you know how could I get the contents of received image for example?

@DouglasAugustoDGS

This comment has been minimized.

Copy link

DouglasAugustoDGS commented Oct 18, 2019

How can I add participants to a group?

@Darknet17

This comment has been minimized.

Copy link

Darknet17 commented Oct 18, 2019

@mikelustosa
Why in the same base64ImageToFile does not accept multiple files, such as pdf, xls, doc, among others that are cases oh that converts it automatically?

@mikelustosa

This comment has been minimized.

Copy link

mikelustosa commented Oct 19, 2019

Can capture JS from console and mount JSON.

In the window.WAPI.getAllContacts function add this line before returning contacts;

console.log (JSON.stringify (contacts));

that way or event in TChromium LogMessage returns or JS from all mobile contacts.

@mikelustosa

This comment has been minimized.