1
- function joinCaseBattle ( ) {
2
-
3
- chrome . storage . local . get ( [ "TARGETS" ] , function ( result ) {
1
+ function joinCaseBattle ( ) {
2
+ chrome . storage . local . get ( [ "TARGETS" ] , function ( result ) {
4
3
const targets = result . TARGETS || [ 'TOXIC' , 'DIABLO' , 'SPARK' , 'ICE BLAST' , 'TEETH' , 'BEAST' , 'SERENITY' , 'JOY' , 'PROGRESS' , 'KITTY' , 'ONYX' ] ;
5
4
( async ( ) => {
6
5
while ( true ) {
7
6
await new Promise ( r => setTimeout ( r , 100 ) ) ;
8
7
try {
9
- const caseNames = ( ( [ ...document . querySelectorAll ( 'p.max-w-full.px-1.overflow-hidden' ) ] ) . splice ( 0 , 10 ) ) . map ( e => e . textContent ) ;
10
- const casePrices = ( ( [ ...document . querySelectorAll ( 'div.flex.items-center.justify-center.rounded-tl-lg' ) ] ) . splice ( 0 , 10 ) ) . map ( e => e . textContent ) ;
11
- if ( casePrices [ caseNames . indexOf ( caseNames . find ( name => targets . includes ( name ) ) ) ] === 'FREE' && caseNames . some ( str => targets . includes ( str ) ) ) {
8
+ const caseNames = [ ...document . querySelectorAll ( 'p.max-w-full.px-1.overflow-hidden' ) ] . splice ( 0 , 5 ) . map ( e => e . textContent ) ;
9
+ const casePrices = [ ...document . querySelectorAll ( 'div.w-fit p.text-center.font-semibold.leading-none' ) ] . splice ( 0 , 5 ) . map ( e => e . textContent ) ;
10
+ const targetIndex = caseNames . findIndex ( name => targets . includes ( name ) ) ;
11
+ if ( casePrices [ targetIndex ] === 'x1' && targetIndex !== - 1 ) {
12
12
const btns = [ ...document . querySelectorAll ( 'a.button.mr-5' ) ] ;
13
- const btn = btns [ caseNames . indexOf ( caseNames . find ( name => targets . includes ( name ) ) ) ] ;
13
+ const btn = btns [ targetIndex ] ;
14
14
btn . click ( ) ;
15
- }
15
+ }
16
16
} catch { null ; }
17
17
}
18
18
} ) ( ) ;
19
- } )
19
+ } ) ;
20
20
}
21
21
22
- document . addEventListener ( "DOMContentLoaded" , function ( ) {
23
- document . getElementById ( "join-button" ) . addEventListener ( 'click' , function ( ) {
22
+ document . addEventListener ( "DOMContentLoaded" , function ( ) {
23
+ document . getElementById ( "join-button" ) . addEventListener ( 'click' , function ( ) {
24
24
chrome . tabs . query ( { active : true , currentWindow : true } , function ( tabs ) {
25
25
if ( tabs . length > 0 ) {
26
26
var tabId = tabs [ 0 ] . id ;
@@ -32,8 +32,8 @@ document.addEventListener("DOMContentLoaded", function(){
32
32
console . error ( "No active tab found." ) ;
33
33
}
34
34
} ) ;
35
- } )
36
- document . getElementById ( "options-button" ) . addEventListener ( 'click' , function ( ) {
35
+ } ) ;
36
+ document . getElementById ( "options-button" ) . addEventListener ( 'click' , function ( ) {
37
37
chrome . runtime . openOptionsPage ( ) ;
38
- } )
39
- } )
38
+ } ) ;
39
+ } ) ;
0 commit comments