Skip to content

Instantly share code, notes, and snippets.

@sonerb
Created August 15, 2017 19:09
Show Gist options
  • Save sonerb/03275c9c4c6f6464ce67f31bca3fd105 to your computer and use it in GitHub Desktop.
Save sonerb/03275c9c4c6f6464ce67f31bca3fd105 to your computer and use it in GitHub Desktop.
web.whatsapp.com phone number extractor
function download(data, filename, type) {
var file = new Blob([data], {type: type});
if (window.navigator.msSaveOrOpenBlob)
window.navigator.msSaveOrOpenBlob(file, filename);
else {
var a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
}
var items = document.querySelectorAll('div.infinite-list-item');
var phone_numbers = [];
for (var i = 0; i < items.length; i++){
var item = items[i];
var src = item.querySelector('div.avatar-body > img').src;
if (src.indexOf('https') > -1)
{
var pieces = src.split('&');
var pieces_2 = pieces[1].split('=');
var number = pieces_2[1];
number = number.substring(0, number.length - 7);
phone_numbers.push(number);
}
}
download(phone_numbers.join("\r\n"), 'whatsapp_phone_numbers.txt', 'text');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment