瀏覽代碼

JavaScript export to filter Market

Mike Greene 8 月之前
父節點
當前提交
d6da08dea9
共有 2 個文件被更改,包括 27 次插入1 次删除
  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');
                 }
             }