-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
103 lines (86 loc) · 4.04 KB
/
index.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// ==UserScript==
// @name Bonusbank Enhancement Suite
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Adds features to enhance your bonusbank.com.au experience.
// @license GPLv3
// @author Chris Aprea
// @match https://bonusbank.com.au/matched-betting-software-lite/
// @match https://bonusbank.com.au/matched-betting-software/
// @icon https://www.google.com/s2/favicons?sz=64&domain_url=https://bonusbank.com.au/
// @resource TOASTIFY_CSS https://cdnjs.cloudflare.com/ajax/libs/toastify-js/1.11.2/toastify.min.css
// @grant GM_getResourceText
// @grant GM_addStyle
// @require https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/toastify-js/1.11.2/toastify.min.js
// ==/UserScript==
/* globals ClipboardJS, Toastify */
(function() {
'use strict';
let isModalOpen = false;
let lastIsModalOpen = false;
let lastBet = '';
const toastifyCss = GM_getResourceText( 'TOASTIFY_CSS' );
GM_addStyle( toastifyCss );
document.addEventListener( 'click', e => {
const eventTarget = e.target;
if ( ! [ 'sr', 'snr' ].includes( eventTarget.parentElement.className ) ) {
return;
}
lastBet = eventTarget.parentElement.parentElement.querySelector( '.bet' ).textContent;
} );
setInterval( () => {
isModalOpen = !! document.querySelector( '.ReactModal__Content' );
if ( isModalOpen === lastIsModalOpen ) {
return;
}
lastIsModalOpen = isModalOpen;
if ( ! isModalOpen ) {
return;
}
const modalContent = document.querySelector( '.ReactModal__Content' );
const stakeElem = document.querySelector( '[name="stake"]' );
const backOddsElem = document.querySelector( '[name="backOdds"]' );
const layOddsElem = document.querySelector( '[name="layOdds"]' );
const layCommissionElem = document.querySelector( '[name="layCommission"]' );
const copyBetToClipboardElement = document.createElement( 'button' );
copyBetToClipboardElement.innerText = 'Copy bet to clipboard';
copyBetToClipboardElement.className = 'btn btn-secondary';
Object.assign( copyBetToClipboardElement.style, {
display: 'block',
margin: '20px auto 0',
} );
new ClipboardJS(
copyBetToClipboardElement,
{
text: () => {
const betSummaryString = document.querySelector( '.css-pdgl6h' ).textContent;
const [mode, sport, event, bookmaker, market] = betSummaryString.split( ' - ' );
const currentDate = new Date();
const data = [
`${currentDate.getDate().toString().padStart(2,'0')}-${(currentDate.getMonth() + 1).toString().padStart(2,'0')}-${currentDate.getFullYear().toString().substr(-2)}`,
bookmaker,
mode.startsWith( 'SNR' ) ? 'Bonus Bet SNR' : 'Wagering Bet',
event,
lastBet,
backOddsElem.value,
layOddsElem.value,
stakeElem.value,
modalContent.querySelector( '.css-meywbh b' ).textContent.substr( 1 ),
`${layCommissionElem.value}%`
];
return data.join( '\t' );
}
}
).on( 'success', () => {
Toastify( {
text: 'Bet copied to clipboard',
duration: 3000,
gravity: 'bottom',
position: 'left',
} ).showToast();
} );
modalContent.insertAdjacentElement( 'beforeend', copyBetToClipboardElement );
modalContent.style.height = `calc( ${modalContent.style.height} + ${copyBetToClipboardElement.offsetHeight + parseInt( window.getComputedStyle(copyBetToClipboardElement).marginTop )}px`;
}, 500 );
})();