Skip to content

Instantly share code, notes, and snippets.

@fiando
Last active July 12, 2018 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiando/f94ef8f58717d1c1505ca581aaf27225 to your computer and use it in GitHub Desktop.
Save fiando/f94ef8f58717d1c1505ca581aaf27225 to your computer and use it in GitHub Desktop.
Javascript Get Whatsapp Number in Group
phoneNumber = []
i = 0;
function saveArray() {
console.log('scroll down !');
nomor = document.querySelectorAll('._2sNbV ._25Ooe ._1wjpf');
nomor.forEach(element => {
n = element.getAttribute('title')
if (phoneNumber.indexOf(n) == -1) {
phoneNumber.push(n);
console.log('Add number : ' + n);
}
else {
console.log('skip duplicate : ' + n);
}
});
}
function getNumber() {
i = 0;
scrollSpeed = 50;
saveArrScroll = document.getElementsByClassName("_2sNbV")[0].addEventListener('scroll', saveArray);
batas = document.getElementsByClassName('AfVTG')[0].clientHeight;
getNumberInterval = setInterval(function(){
scrollDown = document.getElementsByClassName('_2sNbV')[0].scroll(0,i);
if (i > batas) {
clearInterval(getNumberInterval);
document.getElementsByClassName("_2sNbV")[0].removeEventListener('scroll', saveArrScroll);
console.log('OK Selesai ambil nomor');
console.log(phoneNumber);
prompt("Copy nomor ini", JSON.stringify(phoneNumber))
i = 0;
}
i += scrollSpeed;
console.log('scroll ' + i);
}, 100);
}
var start = confirm("Press OK! untuk mulai mengambil!");
if (start == true) {
try {
getNumber();
} catch (e) {
alert('ada kesalahan, pastikan sudah mengklik di group info pada grup Whatsapp Anda');
}
} else {
alert('batal');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment