Bit coin price tracker

by Venkata Sai Vamsi Penupothu

JavaScript

// Here You can type your custom JavaScript...
function doSomething() {
var isSellCheck = true;
var checkPrice = 986179;
var errorMsg = isSellCheck ? sellCheck(checkPrice) : buyCheck(checkPrice);
 if(errorMsg.length >0){
  notifyMe(errorMsg);  
				setTimeout(function () {
        		location.reload();
    			}, 10000); 
 }
}

function sellCheck(minPrice){
var elementByClass = document.getElementsByClassName("bitcoin-sell-price");

var errorMsg = "";

if(elementByClass.length !== 0){
 var elementInnerTextSplit = elementByClass[0].innerText.split("₹ ");
 if(elementInnerTextSplit != null && elementInnerTextSplit.length >0){
 	var currentValue = parseInt(elementInnerTextSplit[1].replace (/,/g, ""));
  if(currentValue >= minPrice){            
        notifyMe("Got a price increase. Current price is "+elementInnerTextSplit[1]);
        console.log("Got a price increase. Current price is "+elementInnerTextSplit[1]);
  }else{
        console.log("not reached our expectation. current price is "+elementInnerTextSplit[1]);    
				setTimeout(function () {
        		location.reload();
    			}, 30000); 
    }  
  }else{
 	errorMsg = "elementInnerTextSplit value is "+elementInnerTextSplit+". Please update the code";
 }
 }else{
 	errorMsg = "elementByClass is empty. Reloading the page";
 }
return errorMsg;
}

function buyCheck(priceLimit){
var elementByClass = document.getElementsByClassName("bitcoin-buy-price");

var errorMsg = "";

if(elementByClass.length !== 0){
 var elementInnerTextSplit = elementByClass[0].innerText.split("₹ ");
 if(elementInnerTextSplit != null && elementInnerTextSplit.length >0){
 	var currentValue = parseInt(elementInnerTextSplit[1].replace (/,/g, ""));
  if(currentValue <= priceLimit){            
        notifyMe("Got a price drop. Current price is "+elementInnerTextSplit[1]);
        console.log("Got a price drop. Current price is "+elementInnerTextSplit[1]);
  }else{
        console.log("not reached our expectation. current price is...