Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
71 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
function getChat(modules) { | ||
for (let idx in modules) { | ||
if (typeof modules[idx] === 'object' && modules[idx] !== null) { | ||
const module = modules[idx]; | ||
const evet = | ||
module.default && module.default.Chat && module.default.Msg | ||
? module.default.Chat | ||
: null; | ||
|
||
if (evet) { | ||
Store['Chat'] = evet; | ||
if (Store && Store.BusinessProfile) { | ||
Store.Chat._findAndParse = Store.BusinessProfile._findAndParse; | ||
Store.Chat._find = Store.BusinessProfile._find; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
import { | ||
filterObjects | ||
} from "./filter-object"; | ||
import { | ||
injectConfig, | ||
filterModule | ||
} from "../../help"; | ||
|
||
export async function addChatWapi() { | ||
const parasite = `chat${Date.now()}`; | ||
window['webpackChunkwhatsapp_web_client'].push([ | ||
[parasite], | ||
window[injectConfig.webpack].push([ | ||
[injectConfig.parasite], | ||
{}, | ||
function (o) { | ||
async function (o) { | ||
let modules = []; | ||
for (let idx in o.m) { | ||
modules.push(o(idx)); | ||
} | ||
getChat(modules); | ||
|
||
const filterMod = await filterModule(filterObjects, modules); | ||
|
||
filterMod.forEach((needObj) => { | ||
if (needObj.yesModule) { | ||
if (!window.Store[needObj.type]) { | ||
window.Store[needObj.type] = needObj.yesModule; | ||
} | ||
} | ||
}); | ||
|
||
if (Store && Store.BusinessProfile) { | ||
Store.Chat._findAndParse = Store.BusinessProfile._findAndParse; | ||
Store.Chat._find = Store.BusinessProfile._find; | ||
} | ||
}, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const filterObjects = [{ | ||
type: 'Chat', | ||
when: (module) => | ||
module.default && module.default.Chat && module.default.Msg ? | ||
module.default.Chat : null | ||
}, | ||
{ | ||
type: 'MaybeMeUser', | ||
when: (module) => (module.getMaybeMeUser ? module : null), | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export async function filterModule(filterObjects, modules) { | ||
let found = 0; | ||
for (let i in modules) { | ||
if (typeof modules[i] === 'object' && modules[i] !== null) { | ||
filterObjects.forEach((needObj) => { | ||
if (!needObj.when | needObj.yesModule) return; | ||
|
||
const checkObj = needObj.when(modules[i]); | ||
if (checkObj !== null) { | ||
found++; | ||
needObj.yesModule = checkObj; | ||
} | ||
}); | ||
if (found == filterObjects.length) { | ||
break; | ||
} | ||
} | ||
} | ||
return filterObjects; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters