mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.04k stars 795 forks source link

It's possible to exit of whatsapp web session? #257

Open gabrieldesousah opened 6 years ago

gabrieldesousah commented 6 years ago

Hello, I need to exit of a session in whatsapp web with this API, or better, using javascript. But I don't find a function to exit of session. Can you help me? Thanks!

brunosoaresds commented 6 years ago

Why don’t you just remove the saved profile and up a new Firefox instance??

gabrieldesousah commented 6 years ago

It's not a good idea exit the browser instance The cellphone will stay connected in two browsers, and for my purpose isn't cool close a window, cause I verify each browser instance..

Em Sáb, 2 de jun de 2018 19:08, Bruno Soares da Silva < notifications@github.com> escreveu:

Why don’t you just remove the saved profile and up a new Firefox instance??

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/257#issuecomment-394120584, or mute the thread https://github.com/notifications/unsubscribe-auth/ALQWYwgcBvyBayJXhHf6aatwu6vY21_lks5t4wzJgaJpZM4UX1_I .

kevinkit commented 6 years ago

How about deleting the elements of the directory containing the sessions saved elemnts? This should give you a new Session on a restart (or simply destroy the wapi Object and create a new one afer deleting the elements)

Gabriel Henrique notifications@github.com schrieb am So., 3. Juni 2018, 16:39:

It's not a good idea exit the browser instance The cellphone will stay connected in two browsers, and for my purpose isn't cool close a window, cause I verify each browser instance..

Em Sáb, 2 de jun de 2018 19:08, Bruno Soares da Silva < notifications@github.com> escreveu:

Why don’t you just remove the saved profile and up a new Firefox instance??

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/257#issuecomment-394120584 , or mute the thread < https://github.com/notifications/unsubscribe-auth/ALQWYwgcBvyBayJXhHf6aatwu6vY21_lks5t4wzJgaJpZM4UX1_I

.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/257#issuecomment-394166847, or mute the thread https://github.com/notifications/unsubscribe-auth/AGhecfTmpzTaG1DP-xQK4JJHnEphDLWsks5t4_UtgaJpZM4UX1_I .

brunosoaresds commented 6 years ago

Can you describe for us your use case/purpose?

dpatil-gmcs commented 6 years ago

@brunosoaresds Please see comment from @Gabrieldesousah

Here is snippet for your reference:

It's not a good idea exit the browser instance The cellphone will stay connected in two browsers, and for my purpose isn't cool close a window, cause I verify each browser instance.

eduardobento commented 6 years ago

Here I found conn object, with logout() method, but it doesnt works any more.

conn = document.querySelector("#app")._reactRootContainer.current.child.child.child.child.child.child.sibling.sibling.sibling.sibling.sibling.memoizedProps.conn._listeningTo.l3;
conn.logout();
kevinkit commented 6 years ago

@eduardobento please format your code in the future

eduardobento commented 6 years ago

Temporary and ugly soluction:

function logout() {
ed = document.getElementsByClassName("rAUz7")[2];
bt = ed.getElementsByTagName("div")[0];
    if (document.createEvent) { 
     var event1 = document.createEvent("MouseEvents"); 
     event1.initEvent("mousedown", true, true);
     bt.dispatchEvent(event1);
    }
ed = document.getElementsByClassName("_3lSL5 _2dGjP")[5];    
ed.click();
}