From 1cd1605b611c3903395aef62bad71badd12c597a Mon Sep 17 00:00:00 2001 From: Felippe Freire Date: Wed, 3 Jun 2020 18:04:55 -0300 Subject: [PATCH 1/4] adapt extension to new version --- webwhatsapi/js/wapi.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/webwhatsapi/js/wapi.js b/webwhatsapi/js/wapi.js index 76c36bbb..68a60a20 100755 --- a/webwhatsapi/js/wapi.js +++ b/webwhatsapi/js/wapi.js @@ -16,6 +16,7 @@ if (!window.Store) { { 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: 'Presence', conditions: (value) => (value.default && value.default.Presence) ? value.default : 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 }, @@ -65,6 +66,15 @@ if (!window.Store) { } } } + + if (window.Store.Presence) { + for (const prop in window.Store.Presence) { + if (prop === "Presence") { + continue; + } + window.Store[prop] = window.Store.Presence[prop] || window.Store[prop]; + } + } } if (typeof webpackJsonp === 'function') { From 3c337f32958efb98d1bc0c6d7279bc2813363ce3 Mon Sep 17 00:00:00 2001 From: Felippe Freire Date: Thu, 4 Jun 2020 09:28:42 -0300 Subject: [PATCH 2/4] fix return store --- webwhatsapi/js/wapi.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webwhatsapi/js/wapi.js b/webwhatsapi/js/wapi.js index 68a60a20..f724dbe3 100755 --- a/webwhatsapi/js/wapi.js +++ b/webwhatsapi/js/wapi.js @@ -62,7 +62,6 @@ if (!window.Store) { window.Store.sendMessage = function (e) { return window.Store.SendTextMsgToChat(this, ...arguments); }; - return window.Store; } } } @@ -75,6 +74,8 @@ if (!window.Store) { window.Store[prop] = window.Store.Presence[prop] || window.Store[prop]; } } + + return window.Store; } if (typeof webpackJsonp === 'function') { From 0116f80e24dd27a703575b704cebb5cf968f2ca6 Mon Sep 17 00:00:00 2001 From: Felippe Freire Date: Sat, 6 Jun 2020 19:19:17 -0300 Subject: [PATCH 3/4] update solution to best code --- webwhatsapi/__init__.py | 2 +- webwhatsapi/consts.py | 2 +- webwhatsapi/js/wapi.js | 13 ++----------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/webwhatsapi/__init__.py b/webwhatsapi/__init__.py index d5d4c670..ed605420 100755 --- a/webwhatsapi/__init__.py +++ b/webwhatsapi/__init__.py @@ -75,7 +75,7 @@ class WhatsAPIDriver(object): "firstrun": "#wrapper", "qrCode": "canvas", "qrCodePlain": "div[data-ref]", - "mainPage": ".app.two", + "mainPage": ".two", "chatList": ".infinite-list-viewport", "messageList": "#main > div > div:nth-child(1) > div > div.message-list", "unreadMessageBar": "#main > div > div:nth-child(1) > div > div.message-list > div.msg-unread", diff --git a/webwhatsapi/consts.py b/webwhatsapi/consts.py index e9f36766..a5c18ba6 100755 --- a/webwhatsapi/consts.py +++ b/webwhatsapi/consts.py @@ -4,7 +4,7 @@ class Selectors(object): FIRST_RUN = "#wrapper" QR_CODE = ".qrcode > img:nth-child(4)" - MAIN_PAGE = ".app.two" + MAIN_PAGE = ".two" CHAT_LIST = ".infinite-list-viewport" MESSAGE_LIST = "#main > div > div:nth-child(1) > div > div.message-list" UNREAD_MESSAGE_BAR = ( diff --git a/webwhatsapi/js/wapi.js b/webwhatsapi/js/wapi.js index f724dbe3..eb162bb0 100755 --- a/webwhatsapi/js/wapi.js +++ b/webwhatsapi/js/wapi.js @@ -11,7 +11,7 @@ if (!window.Store) { function getStore(modules) { let foundCount = 0; let neededObjects = [ - { id: "Store", conditions: (module) => (module.Chat && module.Msg) ? module : null }, + { id: "Store", conditions: (module) => (module.default && module.default.Chat && module.default.Msg) ? module.default : null }, { id: "MediaCollection", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.processAttachments) ? module.default : null }, { id: "MediaProcess", conditions: (module) => (module.BLOB) ? module : null }, { id: "Wap", conditions: (module) => (module.createGroup) ? module : null }, @@ -62,20 +62,11 @@ if (!window.Store) { window.Store.sendMessage = function (e) { return window.Store.SendTextMsgToChat(this, ...arguments); }; - } - } - } - if (window.Store.Presence) { - for (const prop in window.Store.Presence) { - if (prop === "Presence") { - continue; + return window.Store; } - window.Store[prop] = window.Store.Presence[prop] || window.Store[prop]; } } - - return window.Store; } if (typeof webpackJsonp === 'function') { From 92c9f3cbd28f1f980eb7d1c89db8f41d0c3bc8db Mon Sep 17 00:00:00 2001 From: Felippe Freire Date: Sat, 6 Jun 2020 19:20:02 -0300 Subject: [PATCH 4/4] format code --- webwhatsapi/js/wapi.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/webwhatsapi/js/wapi.js b/webwhatsapi/js/wapi.js index eb162bb0..7147688b 100755 --- a/webwhatsapi/js/wapi.js +++ b/webwhatsapi/js/wapi.js @@ -16,7 +16,6 @@ if (!window.Store) { { 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: 'Presence', conditions: (value) => (value.default && value.default.Presence) ? value.default : 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 }, @@ -62,7 +61,6 @@ if (!window.Store) { window.Store.sendMessage = function (e) { return window.Store.SendTextMsgToChat(this, ...arguments); }; - return window.Store; } }