Sfoglia il codice sorgente

JavaScript export to filter Market

Mike Greene 8 mesi fa
parent
commit
d6da08dea9
2 ha cambiato i file con 27 aggiunte e 1 eliminazioni
  1. 26 0
      README.md
  2. 1 1
      market.py

+ 26 - 0
README.md

@@ -73,3 +73,29 @@ 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+="""
+cards=document.getElementsByClassName('wrapper-market-card')
+for (var i = 0; i < cards.length; i++) {
+    cardNum = cards.item(i).getElementsByClassName('pornstar-number')[0].outerText;
+    innerCard = cards.item(i).getElementsByClassName('inner-market-card')[0]
+    let qty = document.createElement('div');
+    qty.innerText = "Stock: " + clist[cardNum]
+    innerCard.appendChild(qty)
+    if (clist[cardNum].includes('CRYSTAL')){
+        cards.item(i).style.setProperty('Display','None');
+    }
+}"""
+print(js)
+```

+ 1 - 1
market.py

@@ -95,7 +95,7 @@ class Market():
                 let qty = document.createElement('div');
                 qty.innerText = "Stock: " + clist[cardNum]
                 innerCard.appendChild(qty)
-                if (clist[cardNum] == 'CRYSTAL'){
+                if (clist[cardNum].includes('CRYSTAL')){
                     cards.item(i).style.setProperty('Display','None');
                 }
             }