You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Send an Email When Price Drops Below a Certain Amount
// run `npm install dotenv`, then place a .env file in the same directory as this scriptrequire('dotenv').config();const{ window }=require('page-evaluate');const{ send }=require('emailjs-gmail')(process.env.GMAIL_USERNAME,process.env.GMAIL_PASSWORD);constgetNumbersOnly=(str)=>(str.match(/[0-9\.]+/g)||[]).join('');constDESIRED_PRICE=50;window('https://example.com').then(({ document })=>{// grab the value of the price element on the pageconstpriceText=document.querySelector('#ProductPrice').textContent.trim();constprice=getNumbersOnly(priceText);// check if the price is low enoughif(Number(price)<=DESIRED_PRICE){// send an emailsend('5555555555@txt.att.net',`Your wildest dream is only $${price} now!`);}});