Browse Source

More javascript enhancements

KeyMasterOfGozer 7 months ago
parent
commit
d7dab28a05
1 changed files with 120 additions and 4 deletions
  1. 120 4
      README.md

+ 120 - 4
README.md

@@ -73,6 +73,62 @@ hist(2)
 plot(2)
 plot(2)
 ```
 ```
 
 
+### 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);}
+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 = cards.item(i).getElementsByClassName('card-nb')[0];
+    if (cardNB){try{
+        cnt = parseInt(cards.item(i).getElementsByClassName('nb-label')[0].outerText.trim());
+        stock["extra"]=cnt-1;
+        var fuzed = cards.item(i).getElementsByClassName('nb-name')[0];
+        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;
+    }
+    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;
+    HTMLText = "Stock: " + clist[cardNum].status + " " + clist[cardNum].extra;
+    innerCard = cards.item(i).getElementsByClassName('inner-market-card')[0];
+    var stock = innerCard.getElementsByClassName('Stock')[0];
+    if (stock){stock.innerText = HTMLText}
+    else {
+        let qty = document.createElement('div');
+        qty.classList.add('Stock');
+        qty.innerText = HTMLText;
+        innerCard.appendChild(qty);
+        }
+    if (clist[cardNum].status == 'CRYSTAL'){
+        cards.item(i).style.setProperty('Display','None');
+    }
+};
+```
+
 ### javascript to filter Market for uncrystalized cards
 ### javascript to filter Market for uncrystalized cards
 ```javascript
 ```javascript
 clist=[];
 clist=[];
@@ -91,13 +147,14 @@ for (var i = 0; i < playerCards.length; i++) {
 cards=document.getElementsByClassName('wrapper-market-card');
 cards=document.getElementsByClassName('wrapper-market-card');
 for (var i = 0; i < cards.length; i++) {
 for (var i = 0; i < cards.length; i++) {
     cardNum = cards.item(i).getElementsByClassName('pornstar-number')[0].outerText;
     cardNum = cards.item(i).getElementsByClassName('pornstar-number')[0].outerText;
+    HTMLText = "Stock: " + clist[cardNum];
     innerCard = cards.item(i).getElementsByClassName('inner-market-card')[0];
     innerCard = cards.item(i).getElementsByClassName('inner-market-card')[0];
     var stock = innerCard.getElementsByClassName('Stock')[0];
     var stock = innerCard.getElementsByClassName('Stock')[0];
-    if (stock){stock.innerText = "Stock: " + clist[cardNum]}
+    if (stock){stock.innerText = HTMLText}
     else {
     else {
         let qty = document.createElement('div');
         let qty = document.createElement('div');
         qty.classList.add('Stock');
         qty.classList.add('Stock');
-        qty.innerText = "Stock: " + clist[cardNum];
+        qty.innerText = HTMLText;
         innerCard.appendChild(qty);
         innerCard.appendChild(qty);
         }
         }
     if (clist[cardNum].toString().includes('CRYSTAL')){
     if (clist[cardNum].toString().includes('CRYSTAL')){
@@ -114,13 +171,14 @@ for (var i = 0; i < cards.length; i++) {
     cardVal = parseInt(cards.item(i).getElementsByClassName('score-card')[0].outerText);
     cardVal = parseInt(cards.item(i).getElementsByClassName('score-card')[0].outerText);
     cardCost = parseInt(cards.item(i).getElementsByClassName('cost')[0].outerText);
     cardCost = parseInt(cards.item(i).getElementsByClassName('cost')[0].outerText);
     cardPPG = cardVal/cardCost;
     cardPPG = cardVal/cardCost;
+    HTMLText = "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];
     innerCard = cards.item(i).getElementsByClassName('inner-market-card')[0];
     var PPG = innerCard.getElementsByClassName('PPG')[0];
     var PPG = innerCard.getElementsByClassName('PPG')[0];
-    if (PPG){PPG.innerHTML = "Points/<img src='https://play.boobylegends.com/wp-content/themes/child-roulette/img/gem.png' style='height:22px'>:<br/>" + cardPPG.toFixed(2);}
+    if (PPG){PPG.innerHTML = HTMLText}
     else {
     else {
         let qty = document.createElement('div');
         let qty = document.createElement('div');
         qty.classList.add('PPG');
         qty.classList.add('PPG');
-        qty.innerHTML = "Points/<img src='https://play.boobylegends.com/wp-content/themes/child-roulette/img/gem.png' style='height:22px'>:<br/>" + cardPPG.toFixed(2);
+        qty.innerHTML = HTMLText;
         qty.setAttribute("align", "center");
         qty.setAttribute("align", "center");
         innerCard.appendChild(qty);
         innerCard.appendChild(qty);
         }
         }
@@ -191,3 +249,61 @@ for (var i = 0; i < cards.length; i++) {
     }
     }
 }
 }
 ```
 ```
+
+### javascript to show overbid cards for sale
+```javascript
+sellThreshold = {};
+sellThreshold["2000"] = 10000;
+sellThreshold["350"] = 195;
+sellThreshold["250"] = 126;
+sellThreshold["200"] =  87;
+sellThreshold["150"] = 110;
+sellThreshold["115"] =  80;
+sellThreshold["75"]  =  32;
+sellThreshold["50"]  =  25;
+sellThreshold["40"]  =  32;
+sellThreshold["20"]  =  22;
+sellThreshold["15"]  =  12;
+sellThreshold["10"]  =   8;
+sellThreshold["4"]   =   9;
+sellThreshold["3"]   =   4;
+sellThreshold["2"]   =   4;
+sellThreshold["1"]   =   4;
+clist=[];
+for (var i = 0; i < 153; i++) {clist.push(0);}
+let market = document.createElement('div');
+market.id = 'market';
+market.innerHTML=await (await fetch('https://play.boobylegends.com/market/')).text();
+marketCards=market.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());
+    clist[cardNum]=price;
+    }catch(err){console.log('error on '+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;
+    HTMLText = "Current Bid: "+clist[cardNum].toString()+"<br/>Threshold: "+sellThreshold[cardVal.toString()];
+    innerCard = cards.item(i).getElementsByClassName('inner-market-card')[0];
+    var PPG = innerCard.getElementsByClassName('PPG')[0];
+    if (PPG){PPG.innerHTML = HTMLText}
+    else {
+        let qty = document.createElement('div');
+        qty.classList.add('PPG');
+        qty.innerHTML = HTMLText;
+        qty.setAttribute("align", "center");
+        innerCard.appendChild(qty);
+        }
+    if (cardCost <= clist[cardNum]){
+        cards.item(i).style.setProperty('Display','None');
+    }
+    if (clist[cardNum] < sellThreshold[cardVal.toString()]){
+        cards.item(i).style.setProperty('Display','None');
+    }
+}
+```