Advertisement
jaggerid

CB market filter

Aug 7th, 2021
1,572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. var summary = document.querySelectorAll(".above-wrapper")
  3. for(k=summary.length-1; k > -1; k--){
  4.     var type = [".int",".str",".dex",".pwr",".cha"]
  5.     var match = false;
  6.     var matchs = 0, wpow = 0, lpow = 0, epow = 0, fpow = 0;
  7.     var weles = summary[k].offsetParent.querySelector(".trait").firstChild.className.trim();
  8.     var price = parseFloat(summary[k].innerText.substring(7,11));
  9.  
  10.     if(weles == "lightning-icon"){trait = "CHA";}
  11.     else if(weles == "water-icon"){trait = "INT";}
  12.     else if(weles == "earth-icon"){trait = "DEX";}
  13.     else if(weles == "fire-icon"){trait = "STR";}
  14.    
  15.     for (j = 0; j < type.length; j++){
  16.         var divs = summary[k].offsetParent.querySelectorAll(type[j]), i
  17.         for (i = 0; i < divs.length; ++i) {
  18.             var stat = divs[i].innerText.trim();
  19.             var ele = stat.substring(0, 3);
  20.                
  21.             stat = parseInt(stat.substring(stat.length - 3, stat.length));
  22.            
  23.             if(ele == trait){match = true; matchs++;}
  24.            
  25.             if(ele == "CHA"){
  26.                 lpow = lpow + stat * 0.002675;
  27.                 wpow = wpow + stat * 0.0025;
  28.                 epow = epow + stat * 0.0025;
  29.                 fpow = fpow + stat * 0.0025;
  30.             }
  31.             else if(ele == "INT"){
  32.                 wpow = wpow + stat * 0.002675;
  33.                 epow = epow + stat * 0.0025;
  34.                 fpow = fpow + stat * 0.0025;
  35.                 lpow = lpow + stat * 0.0025;
  36.             }
  37.             else if(ele == "DEX"){
  38.                 epow = epow + stat * 0.002675;
  39.                 wpow = wpow + stat * 0.0025;
  40.                 fpow = fpow + stat * 0.0025;
  41.                 lpow = lpow + stat * 0.0025;
  42.             }
  43.             else if(ele == "STR"){
  44.                 fpow = fpow + stat * 0.002675;
  45.                 wpow = wpow + stat * 0.0025;
  46.                 epow = epow + stat * 0.0025;
  47.                 lpow = lpow + stat * 0.0025;
  48.             }
  49.             else if(ele == "PWR"){
  50.                 wpow = wpow + stat * 0.002575;
  51.                 epow = epow + stat * 0.002575;
  52.                 fpow = fpow + stat * 0.002575;
  53.                 lpow = lpow + stat * 0.002575;
  54.             }
  55.         }
  56.     }
  57.     if(wpow >= Math.max(epow, fpow, lpow)){
  58.         summary[k].offsetParent.querySelector(".name").innerText = "Water : " + (wpow * 100).toFixed(2) + " %";
  59.     }
  60.     if(epow >= Math.max(wpow, fpow, lpow)){
  61.         summary[k].offsetParent.querySelector(".name").innerText = "Earth : " + (epow * 100).toFixed(2) + " %";
  62.     }
  63.     if(fpow >= Math.max(epow, fpow, lpow)){
  64.         summary[k].offsetParent.querySelector(".name").innerText = "Fire : " + (fpow * 100).toFixed(2) + " %";
  65.     }
  66.     if(lpow >= Math.max(wpow, fpow, epow)){
  67.         summary[k].offsetParent.querySelector(".name").innerText = "Lightning : " + (lpow * 100).toFixed(2) + " %";
  68.     }
  69.    
  70.     if(summary[k].offsetParent.querySelector(".sold") != null){
  71.         summary[k].offsetParent.style.display = "none";;
  72.     }
  73.     // else if(matchs >= 2){} //if match 2 or more
  74.     else if(match == true){} //if match 1 or more
  75.     else if(price < 4){} //if price less than x
  76.     else if(Math.max(epow, fpow, lpow, wpow) >= 2.8){} //if multiplier more than x (3.21 is the max, match 3 400 value)
  77.     else{
  78.         summary[k].offsetParent.style.display = "none";;
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement