Procházet zdrojové kódy

Add more JS examples

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

+ 38 - 0
README.md

@@ -179,6 +179,44 @@ for (var i = 0; i < cards.length; i++) {
 } //Player page show number cards for sale
 ```
 
+##### javascript to show only cards for sale
+```javascript
+numForSale=[];
+for (var i = 0; i < 153; i++) {numForSale.push(0);}
+let marketSelling = document.createElement('div');
+marketSelling.id = 'market';
+marketSelling.innerHTML=await (await fetch('https://play.boobylegends.com/market/?tab=selling')).text();
+marketCards=marketSelling.getElementsByClassName('wrapper-market-card');
+for (var i = 0; i < marketCards.length; i++) {
+    try{
+    cardNum = parseInt(marketCards.item(i).getElementsByClassName('pornstar-number')[0].innerText);
+    price = parseInt(marketCards.item(i).getElementsByClassName('cost')[0].innerText.trim());
+    numForSale[cardNum]=numForSale[cardNum]+1;
+    }catch(err){console.log('error on '+cardNum.toString());}
+};
+cards=document.getElementsByClassName('wrapper-card');
+for (var i = 0; i < cards.length; i++) {
+    cardNum = parseInt(cards.item(i).getElementsByClassName('pornstar-number')[0].outerText);
+    cardVal = parseInt(cards.item(i).getElementsByClassName('score-card')[0].outerText);
+    if (numForSale[cardNum] > 0){
+        HTMLText = " +" + numForSale[cardNum];
+    }else{HTMLText=""; cards.item(i).style.setProperty('Display','None');}
+    var cardNB = cards.item(i).getElementsByClassName('card-nb')[0];
+    if (cardNB){try{
+        var priceDiv = cardNB.getElementsByClassName('Price')[0];
+        if (priceDiv){priceDiv.innerText = HTMLText;}
+        else{
+            let qty = document.createElement('div');
+            qty.classList.add('Price');
+            qty.innerText = HTMLText;
+            cardNB.appendChild(qty);
+        }
+    }catch(err){stock=0;}}else{
+        stock=0;
+    }
+} //Player page show only cards for sale
+```
+
 #### Market Page
 
 ##### javascript to filter Market for needed cards