Skip to content

Instantly share code, notes, and snippets.

@ttycelery
Last active May 23, 2024 19:33
Show Gist options
  • Save ttycelery/b9fe5a1a8326cab77a4a4c97755f0552 to your computer and use it in GitHub Desktop.
Save ttycelery/b9fe5a1a8326cab77a4a4c97755f0552 to your computer and use it in GitHub Desktop.
WhatsApp Group Phone Number Grabber: grab all (unsaved) phone numbers in WhatsApp group
/*
Paste the following minified script to browser console (with WhatsApp Web open)
---------------
var phone_list=[];function get_list(e){var t=document.getElementsByClassName("O90ur")[0].innerText;t=t.split(", ");for(var l=0;l<t.length;l++)num=t[l].replace(/[^0-9]/g,""),"6"==num.charAt(0)&&(phone_list.includes(num)||phone_list.push(num));e&&alert(phone_list.join("\n"))}function doc_keyUp(e){e.ctrlKey&&57==e.keyCode?get_list(!0):e.ctrlKey&&56==e.keyCode?(get_list(!1),document.title="List successfully captured!"):e.ctrlKey&&55==e.keyCode?(phone_list=[],document.title="List successfully cleared!"):e.ctrlKey&&54==e.keyCode&&(document.title="Current list length: "+phone_list.length)}document.addEventListener("keyup",doc_keyUp,!1);
---------------
After entering above text, you can use these hotkeys:
- CTRL+9: capture current group chat phone numbers (unsaved numbers) and display an alert()
- CTRL+8: capture current group chat phone numbers and show notification in page title
- CTRL+7: clear captured phone_number list and show notification in page title
- CTRL+6: show current list length in page title
Not minified script:
*/
var phone_list = [];
function get_list(alert_x) {
var l=document.getElementsByClassName("O90ur")[0].innerText;
l = l.split(", ");
for (var i = 0; i < l.length; i++) {
num = l[i].replace(/[^0-9]/g,"");
if(num.charAt(0) == "6") {
if(!phone_list.includes(num)) {
phone_list.push(num);
}
}
}
if(alert_x) {
alert(phone_list.join("\n"));
}
}
function doc_keyUp(e) {
if (e.ctrlKey && e.keyCode == 57) {
get_list(true);
} else if (e.ctrlKey && e.keyCode == 56) {
get_list(false);
document.title = "List successfully captured!";
} else if (e.ctrlKey && e.keyCode == 55) {
phone_list = []
document.title = "List successfully cleared!";
} else if (e.ctrlKey && e.keyCode == 54) {
document.title = "Current list length: " + phone_list.length;
}
}
document.addEventListener('keyup', doc_keyUp, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment