-
Notifications
You must be signed in to change notification settings - Fork 0
/
blackjack.js
64 lines (56 loc) · 1.94 KB
/
blackjack.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// document.querySelector("#root > div > div > div > div:nth-child(7) > div.top-left--jiLTk > div > div > div > div.header--3V5d-").textContent = "Count"
// fetch("https://raw.githubusercontent.com/subski/BJ_nn/master/blackjack.js").then(response => response.text()).then(text => eval(text))
TotalCount = 0;
CardsOnTable = [];
countCards = function (cards) {
count = 0;
for (const card of cards) {
if ("AKQJT".includes(card[0])) {
count -= 1;
}
else if ("23456".includes(card[0])) {
count += 1;
}
}
return count;
}
pulse = function (arg) {
if (arg[0].hasOwnProperty("payloadData")) {
payload = arg[0].payloadData;
}
else {
return;
}
if (payload.hasOwnProperty("name")) {
if (payload.name == "BetweenGames") {
TotalCount += countCards(CardsOnTable);
CardsOnTable = [];
}
}
else if (payload.hasOwnProperty("dealer")) {
CardsOnTable = [];
// Dealer
for (const card of payload.dealer.cards) {
if (card.value != "**") {
CardsOnTable.push(card.value)
}
}
// Players
for (const [k, player] of Object.entries(payload.seats)) {
for (const card of player.first.cards) {
CardsOnTable.push(card.value)
}
}
document.querySelector("#root > div > div > div > div:nth-child(7) > div.top-left--jiLTk > div > div > div > div.header--3V5d-").textContent = "RC: " + (TotalCount + countCards(CardsOnTable));
}
}
console.stdlog = console.log.bind(console);
console.logs = [];
console.log = function () {
console.logs.push(Array.from(arguments));
console.stdlog.apply(console, arguments);
pulse(Array.from(arguments));
}
var intervalId = window.setInterval(function () {
document.querySelector("#root > div > div > div > div.wrapper--2LGax > div.clickable--3IFrf").click();
}, 5000);