Aviator Rain Auto Claimer

Automatically claims rain when it appears in the chat

Size

8.5 KB

Version

1.0.1

Created

Mar 15, 2026

Updated

6 days ago

1// ==UserScript==
2// @name		Aviator Rain Auto Claimer
3// @description		Automatically claims rain when it appears in the chat
4// @version		1.0.1
5// @match		https://*.legacy.hollywoodbets.net/*
6// @icon		https://legacy.hollywoodbets.net/assets/images/pwa/favicon.ico
7// @grant		GM.getValue
8// @grant		GM.setValue
9// ==/UserScript==
10(function() {
11    'use strict';
12
13    console.log('Aviator Rain Auto Claimer - Extension loaded');
14
15    // Debounce function to prevent excessive calls
16    function debounce(func, wait) {
17        let timeout;
18        return function executedFunction(...args) {
19            const later = () => {
20                clearTimeout(timeout);
21                func(...args);
22            };
23            clearTimeout(timeout);
24            timeout = setTimeout(later, wait);
25        };
26    }
27
28    // Function to check for rain notifications and claim them
29    async function checkForRain() {
30        try {
31            // Look for rain-related elements in the main document
32            const rainElements = document.querySelectorAll('[class*="rain" i], [id*="rain" i]');
33            
34            // Check for rain claim buttons
35            const claimButtons = document.querySelectorAll('button[class*="claim" i], a[class*="claim" i], div[class*="claim" i]');
36            
37            // Look for rain notifications in text content
38            const allElements = document.querySelectorAll('div, span, p, button, a');
39            
40            for (const element of allElements) {
41                const text = element.textContent.toLowerCase();
42                
43                // Check if element contains rain-related text
44                if (text.includes('rain') && (text.includes('claim') || text.includes('collect') || text.includes('get'))) {
45                    console.log('Rain notification detected:', element.textContent);
46                    
47                    // Try to find and click the claim button
48                    if (element.tagName === 'BUTTON' || element.tagName === 'A') {
49                        console.log('Clicking rain claim button');
50                        element.click();
51                        
52                        // Log the claim
53                        const claimCount = await GM.getValue('rainClaimCount', 0);
54                        await GM.setValue('rainClaimCount', claimCount + 1);
55                        await GM.setValue('lastRainClaim', new Date().toISOString());
56                        
57                        console.log(`Rain claimed successfully! Total claims: ${claimCount + 1}`);
58                        return true;
59                    }
60                    
61                    // If it's not a button, look for a clickable child
62                    const clickableChild = element.querySelector('button, a, [onclick]');
63                    if (clickableChild) {
64                        console.log('Clicking rain claim element');
65                        clickableChild.click();
66                        
67                        const claimCount = await GM.getValue('rainClaimCount', 0);
68                        await GM.setValue('rainClaimCount', claimCount + 1);
69                        await GM.setValue('lastRainClaim', new Date().toISOString());
70                        
71                        console.log(`Rain claimed successfully! Total claims: ${claimCount + 1}`);
72                        return true;
73                    }
74                }
75            }
76            
77            // Check iframes for rain notifications (if accessible)
78            const iframes = document.querySelectorAll('iframe');
79            for (const iframe of iframes) {
80                try {
81                    const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
82                    if (iframeDoc) {
83                        const iframeElements = iframeDoc.querySelectorAll('div, span, p, button, a');
84                        
85                        for (const element of iframeElements) {
86                            const text = element.textContent.toLowerCase();
87                            
88                            if (text.includes('rain') && (text.includes('claim') || text.includes('collect') || text.includes('get'))) {
89                                console.log('Rain notification detected in iframe:', element.textContent);
90                                
91                                if (element.tagName === 'BUTTON' || element.tagName === 'A') {
92                                    console.log('Clicking rain claim button in iframe');
93                                    element.click();
94                                    
95                                    const claimCount = await GM.getValue('rainClaimCount', 0);
96                                    await GM.setValue('rainClaimCount', claimCount + 1);
97                                    await GM.setValue('lastRainClaim', new Date().toISOString());
98                                    
99                                    console.log(`Rain claimed successfully! Total claims: ${claimCount + 1}`);
100                                    return true;
101                                }
102                                
103                                const clickableChild = element.querySelector('button, a, [onclick]');
104                                if (clickableChild) {
105                                    console.log('Clicking rain claim element in iframe');
106                                    clickableChild.click();
107                                    
108                                    const claimCount = await GM.getValue('rainClaimCount', 0);
109                                    await GM.setValue('rainClaimCount', claimCount + 1);
110                                    await GM.setValue('lastRainClaim', new Date().toISOString());
111                                    
112                                    console.log(`Rain claimed successfully! Total claims: ${claimCount + 1}`);
113                                    return true;
114                                }
115                            }
116                        }
117                    }
118                } catch (e) {
119                    // Iframe access denied, skip
120                }
121            }
122            
123        } catch (error) {
124            console.error('Error checking for rain:', error);
125        }
126        
127        return false;
128    }
129
130    // Debounced version of checkForRain
131    const debouncedCheckForRain = debounce(checkForRain, 500);
132
133    // Set up MutationObserver to watch for DOM changes
134    function setupObserver() {
135        const observer = new MutationObserver(debouncedCheckForRain);
136        
137        observer.observe(document.body, {
138            childList: true,
139            subtree: true,
140            characterData: true
141        });
142        
143        console.log('Rain monitor active - watching for rain notifications');
144        
145        // Also observe iframes
146        const iframes = document.querySelectorAll('iframe');
147        iframes.forEach(iframe => {
148            try {
149                const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
150                if (iframeDoc && iframeDoc.body) {
151                    const iframeObserver = new MutationObserver(debouncedCheckForRain);
152                    iframeObserver.observe(iframeDoc.body, {
153                        childList: true,
154                        subtree: true,
155                        characterData: true
156                    });
157                    console.log('Monitoring iframe for rain notifications');
158                }
159            } catch (e) {
160                // Iframe access denied
161            }
162        });
163    }
164
165    // Initialize the extension
166    async function init() {
167        console.log('Initializing Aviator Rain Auto Claimer');
168        
169        // Wait for page to be fully loaded
170        if (document.readyState === 'loading') {
171            document.addEventListener('DOMContentLoaded', () => {
172                setTimeout(() => {
173                    setupObserver();
174                    checkForRain(); // Initial check
175                }, 2000);
176            });
177        } else {
178            setTimeout(() => {
179                setupObserver();
180                checkForRain(); // Initial check
181            }, 2000);
182        }
183        
184        // Periodic check every 5 seconds as backup
185        setInterval(checkForRain, 5000);
186        
187        // Display stats on console
188        const claimCount = await GM.getValue('rainClaimCount', 0);
189        const lastClaim = await GM.getValue('lastRainClaim', 'Never');
190        console.log(`Rain Auto Claimer Stats - Total claims: ${claimCount}, Last claim: ${lastClaim}`);
191    }
192
193    // Start the extension
194    init();
195})();