Browse Source

Add some javascript filters

KeyMasterOfGozer 8 tháng trước cách đây
mục cha
commit
e95be90388
1 tập tin đã thay đổi với 30 bổ sung16 xóa
  1. 30 16
      README.md

+ 30 - 16
README.md

@@ -73,19 +73,21 @@ hist(2)
 plot(2)
 ```
 
-### Get javascript to filter Market
-```python
-from datetime import datetime
-from db import PlayerDB
-from tinydb import Query
-import json
-today=datetime.utcnow().strftime('%Y-%m-%d')
-Cards=PlayerDB.search(Query().fragment({'date':today}))
-clist=[None]*152
-for card in Cards: clist[card['card-num']]=card['stock']
-
-js="clist={clist}\n".format(clist=json.dumps(clist))
-js+="""
+### javascript to filter Market for uncrystalized cards
+```javascript
+clist=[]
+for (var i = 0; i < 153; i++) {clist.push(-1);}
+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++) {
+    try{
+    cardNum = parseInt(playerCards.item(i).getElementsByClassName('pornstar-number')[0].innerText);
+    stock = playerCards.item(i).getElementsByClassName('card-nb')[0].innerText.trim();
+    clist[cardNum]=stock;
+    }catch(err){console.log('hi');}
+};
 cards=document.getElementsByClassName('wrapper-market-card')
 for (var i = 0; i < cards.length; i++) {
     cardNum = cards.item(i).getElementsByClassName('pornstar-number')[0].outerText;
@@ -98,9 +100,21 @@ for (var i = 0; i < cards.length; i++) {
         qty.innerText = "Stock: " + clist[cardNum]
         innerCard.appendChild(qty)
         }
-    if (clist[cardNum].includes('CRYSTAL')){
+    if (clist[cardNum].toString().includes('CRYSTAL')){
         cards.item(i).style.setProperty('Display','None');
     }
-}"""
-print(js)
+}
+```
+
+### javascript to filter Market for good value cards
+```javascript
+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);
+    if (cardCost > (cardVal/2)){
+        cards.item(i).style.setProperty('Display','None');
+    }
+}
 ```