Created
June 20, 2019 19:51
-
-
Save sergiks/b431a8cbe6a6c0420b1e13f29d419bdf to your computer and use it in GitHub Desktop.
WhatsApp two groups members intersect
This file contains hidden or 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
(() => { | |
const B = '+7 901 555-55-55, +7 903 777-77-77' | |
.split(', ').sort(); | |
const A = '+7 901 555-55-55, +7 926 222-22-22' | |
.split(', ').sort(); | |
const both = [], onlyA = [], onlyB = [], lA = A.length, lB = B.length; | |
let iA = 0, iB = 0; | |
while(true) { | |
if (iA >= lA) { | |
onlyB.push(...B.splice(iB)); | |
break; | |
} | |
if (iB >= lB) { | |
onlyA.push(...A.splice(iA)); | |
break; | |
} | |
const cA = A[iA]; | |
const cB = B[iB]; | |
if (cA > cB) { | |
onlyB.push(cB); | |
iB++ | |
continue; | |
} else if (cA < cB) { | |
onlyA.push(cA); | |
iA++; | |
continue; | |
} else { | |
both.push(cA); | |
iA++; | |
iB++; | |
continue; | |
} | |
} | |
console.log("%d both: %s", both.length, JSON.stringify(both)); | |
console.log("%d in A only: %s", onlyA.length, JSON.stringify(onlyA)); | |
console.log("%d in B only: %s", onlyB.length, JSON.stringify(onlyB)); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To grab a list of group members from WhatsApp web, open browser's Development Tools and "Inspect element" that displays group members on top of the dialog window. Copy Inner HTML of that span - it has phone numbers or names of the users from your phonebook.