Skip to content

Commit 780523f

Browse files
committed
halfMax
1 parent e898248 commit 780523f

File tree

5 files changed

+84
-2
lines changed

5 files changed

+84
-2
lines changed

lib/content.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function observe(mutations) {
1717
}
1818

1919
for (const node of mutation.removedNodes) {
20-
if (node.classList.contains('ModalItem')) {
20+
if (node.classList && node.classList.contains('ModalItem')) {
2121
removeAttributes();
2222
}
2323
}

lib/patches.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import playerStats from './patches/playerStats.js';
22
import abslveLink from './patches/abslveLink.js';
33
import colorEmoji from './patches/colorEmoji.js';
44
import currencyEndpoint from './patches/currencyEndpoint.js';
5+
import halfMax from './patches/halfMax.js';
56

6-
const patches = [playerStats, abslveLink, colorEmoji, currencyEndpoint];
7+
const patches = [playerStats, abslveLink, colorEmoji, currencyEndpoint, halfMax];
78

89
export default patches;

lib/patches/halfMax.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import runOnPage from '../runOnPage.js';
2+
import { eventHandlers } from '../react.js';
3+
4+
async function patch(maxButton) {
5+
let betForm = maxButton.closest('.ModalForm-Form-Inputs-Amount');
6+
let betInput = betForm.querySelector('.form-control');
7+
8+
const maxBet = Number(/ ([0-9]+)$/.exec(maxButton.textContent)[1]);
9+
const halfMax = maxBet / 2;
10+
11+
let betContainer = document.createElement('div');
12+
betContainer.classList.add('ModalForm-Form-Inputs-Amount-MaxContainer');
13+
betContainer.append(maxButton);
14+
15+
let halfButton = document.createElement('a');
16+
halfButton.classList.add('ModalForm-Form-Inputs-Amount-Max');
17+
halfButton.addEventListener('click', event => {
18+
event.preventDefault();
19+
runOnPage((betInput, halfMax, eventHandlers) => {
20+
betInput.value = halfMax;
21+
eventHandlers(betInput).onChange({ target: betInput });
22+
})(betInput, halfMax, eventHandlers);
23+
});
24+
halfButton.textContent = `50% Bet: ${halfMax}`;
25+
betContainer.append(halfButton);
26+
27+
betForm.append(betContainer);
28+
}
29+
30+
const halfMax = {
31+
name: 'halfMax',
32+
selector: '.ModalForm-Form-Inputs-Amount > .ModalForm-Form-Inputs-Amount-Max',
33+
path: /^\/bet\//,
34+
apply: patch
35+
};
36+
37+
export default halfMax;

lib/react.js

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ export function fiber(node) {
66
}
77
}
88

9+
export function eventHandlers(node) {
10+
for (const key in node) {
11+
if (key.startsWith('__reactEventHandlers$')) {
12+
return node[key];
13+
}
14+
}
15+
}
16+
917
export function state(fiber) {
1018
if (fiber.memoizedState.memoizedState) {
1119
return fiber.memoizedState.memoizedState;

lib/style.css

+36
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,39 @@ div.Player-Info-Line-Triple {
4848
.Player-Info-Line-Category {
4949
text-align: center;
5050
}
51+
52+
#root div.ModalForm-Form-Inputs-Amount {
53+
display: grid;
54+
grid-template-columns: 1fr min-content;
55+
grid-template-rows: min-content max-content;
56+
}
57+
58+
#root .ModalForm-Form-Inputs-Amount > * {
59+
grid-column: 1 / 3;
60+
}
61+
62+
#root div.ModalForm-Form-Inputs-Amount input[type="range"] {
63+
height: auto;
64+
width: 100%;
65+
position: static;
66+
grid-column: 1;
67+
}
68+
69+
#root div.ModalForm-Form-Inputs-Amount-MaxContainer {
70+
display: flex;
71+
flex-direction: column;
72+
gap: 4px;
73+
grid-column: 2;
74+
}
75+
76+
#root .ModalForm-Form-Inputs-Amount-Max {
77+
position: static;
78+
bottom: 0;
79+
right: 0;
80+
white-space: nowrap;
81+
}
82+
83+
#root div.ModalForm {
84+
max-height: auto;
85+
overflow: auto;
86+
}

0 commit comments

Comments
 (0)