Procházet zdrojové kódy

New Javascript filters

Mike Greene před 6 měsíci
rodič
revize
ba43040e3e
1 změnil soubory, kde provedl 80 přidání a 20 odebrání
  1. 80 20
      README.md

+ 80 - 20
README.md

@@ -221,8 +221,8 @@ for (var i = 0; i < cards.length; i++) {
 
 ##### javascript to filter Market for needed cards
 ```javascript
-clist=[];
-for (var i = 0; i < 153; i++) {x={};x["extra"]=0;x["status"]="NORMAL";clist.push(x);}
+playerStock=[];
+for (var i = 0; i < 153; i++) {x={};x["extra"]=0;x["status"]="NORMAL";playerStock.push(x);}
 let player = document.createElement('div');
 player.id = 'player';
 player.innerHTML=await (await fetch('https://play.boobylegends.com/player/')).text();
@@ -233,33 +233,30 @@ for (var i = 0; i < playerCards.length; i++) {
     stock["status"]="NORMAL";
     try{
     cardNum = parseInt(playerCards.item(i).getElementsByClassName('pornstar-number')[0].innerText);
-    var cardNB = cards.item(i).getElementsByClassName('card-nb')[0];
-    if (cardNB){try{
-        cnt = parseInt(cards.item(i).getElementsByClassName('nb-label')[0].outerText.trim());
+    var cardNB = playerCards.item(i).getElementsByClassName('card-nb')[0];
+    if (cardNB){
+        try{
+        cnt = parseInt(cardNB.getElementsByClassName('nb-label')[0].outerText.trim());
+        }catch(err){cnt=0;}
         stock["extra"]=cnt-1;
-        var fuzed = cards.item(i).getElementsByClassName('nb-name')[0];
+        try{
+        var fuzed = cardNB.getElementsByClassName('nb-name')[0].outerText.trim();
         if (fuzed){
             stock["extra"] = stock["extra"] + 1;
             stock["status"]= fuzed;
             }
-        var priceDiv = cardNB.getElementsByClassName('Price')[0];
-        if (priceDiv){priceDiv.innerText = "Price: " + price;}
-        else{
-            let qty = document.createElement('div');
-            qty.classList.add('Price');
-            qty.innerText = "Price: " + price;
-            cardNB.appendChild(qty);
-        }
-    }catch(err){stock=stock;}}else{
-        stock=stock;
+        }catch(err){console.log('No Status, or Normal Card : '+cardNum.toString());}
+        playerStock[cardNum]=stock;
     }
-    clist[cardNum]=stock;
-    }catch(err){console.log('hi');}
+    }catch(err){console.log('Error on Card : '+cardNum.toString());}
 };
 cards=document.getElementsByClassName('wrapper-market-card');
 for (var i = 0; i < cards.length; i++) {
     cardNum = cards.item(i).getElementsByClassName('pornstar-number')[0].outerText;
-    HTMLText = "Stock: " + clist[cardNum].status + " " + clist[cardNum].extra;
+    if (playerStock[cardNum].status != "NORMAL"){
+        HTMLText=playerStock[cardNum].status + " +"
+    }else{HTMLText=""}
+    HTMLText = "Stock: " + HTMLText + playerStock[cardNum].extra;
     innerCard = cards.item(i).getElementsByClassName('inner-market-card')[0];
     var stock = innerCard.getElementsByClassName('Stock')[0];
     if (stock){stock.innerText = HTMLText}
@@ -269,12 +266,75 @@ for (var i = 0; i < cards.length; i++) {
         qty.innerText = HTMLText;
         innerCard.appendChild(qty);
         }
-    if (clist[cardNum].status == 'CRYSTAL'){
+    if (playerStock[cardNum].status == 'CRYSTAL'){
         cards.item(i).style.setProperty('Display','None');
     }
 } //filter Market for needed cards
 ```
 
+##### javascript to filter Market for good buys for needed cards
+```javascript
+playerStock=[];
+for (var i = 0; i < 153; i++) {x={};x["extra"]=0;x["status"]="NORMAL";playerStock.push(x);}
+let player = document.createElement('div');
+player.id = 'player';
+player.innerHTML=await (await fetch('https://play.boobylegends.com/player/')).text();
+playerCards=player.getElementsByClassName('wrapper-card');
+for (var i = 0; i < playerCards.length; i++) {
+    stock = {};
+    stock["extra"]=0;
+    stock["status"]="NORMAL";
+    try{
+    cardNum = parseInt(playerCards.item(i).getElementsByClassName('pornstar-number')[0].innerText);
+    var cardNB = playerCards.item(i).getElementsByClassName('card-nb')[0];
+    if (cardNB){
+        try{
+        cnt = parseInt(cardNB.getElementsByClassName('nb-label')[0].outerText.trim());
+        }catch(err){cnt=0;}
+        stock["extra"]=cnt-1;
+        try{
+        var fuzed = cardNB.getElementsByClassName('nb-name')[0].outerText.trim();
+        if (fuzed){
+            stock["extra"] = stock["extra"] + 1;
+            stock["status"]= fuzed;
+            }
+        }catch(err){console.log('No Status, or Normal Card : '+cardNum.toString());}
+        playerStock[cardNum]=stock;
+    }
+    }catch(err){console.log('Error on Card : '+cardNum.toString());}
+};
+cards=document.getElementsByClassName('wrapper-market-card');
+for (var i = 0; i < cards.length; i++) {
+    cardNum = cards.item(i).getElementsByClassName('pornstar-number')[0].outerText;
+    cardVal = parseInt(cards.item(i).getElementsByClassName('score-card')[0].outerText);
+    cardCost = parseInt(cards.item(i).getElementsByClassName('cost')[0].outerText);
+    cardPPG = cardVal/cardCost;
+    if (playerStock[cardNum].status != "NORMAL"){
+        HTMLText=playerStock[cardNum].status + " +"
+    }else{HTMLText=""}
+    HTMLText = "Stock: " + HTMLText + playerStock[cardNum].extra;
+    HTMLText = HTMLText+"<br/>"+
+            "Points/<img src='https://play.boobylegends.com/wp-content/themes/child-roulette/img/gem.png' style='height:22px'>:<br/>" + cardPPG.toFixed(2);
+    innerCard = cards.item(i).getElementsByClassName('inner-market-card')[0];
+    var extraInfo = innerCard.getElementsByClassName('extraInfo')[0];
+    if (extraInfo){extraInfo.innerHTML = HTMLText}
+    else {
+        let extraInfoDiv = document.createElement('div');
+        extraInfoDiv.classList.add('extraInfo');
+        extraInfoDiv.innerHTML = HTMLText;
+        extraInfoDiv.setAttribute("align", "center");
+        innerCard.appendChild(extraInfoDiv);
+        }
+    if (playerStock[cardNum].status == 'CRYSTAL'){
+        cards.item(i).style.setProperty('Display','None');
+    }
+    if (cardPPG < 2){
+        cards.item(i).style.setProperty('Display','None');
+    }
+} //filter Market for good buys for needed cards
+```
+
+
 ##### javascript to filter Market for uncrystalized cards
 ```javascript
 clist=[];