`
const puppeteer = require('puppeteer');
(async function(){
try{
const browser = await puppeteer.launch({ headless:false })
const page = await browser.newPage()
await page.setUserAgent(
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
);
await page.goto("https://web.whatsapp.com/")
await page.waitForSelector("._13NKt");
await delay(5000)
const contactName = "Corona Bot";
await page.click(`span[title='${contactName}']`);
await page.waitForSelector('.fd365im1')
const amountOfMessages = 10;
for(var i =0; i<amountOfMessages; i++){
await page.type(".p3_M1", "Hi, how are you, I hope you are good!");
delay(2000)
await page.keyboard.press("Enter");
await delay(500)
}
}catch(err){
console.log(err)
}
})();
function delay(time){
return new Promise(function(resolve){
setTimeout(resolve, time)
})
}
`
Top comments (0)