Kiddy Earner Auto Surf

Automatically surfs ads on kiddyearner.com

Size

5.8 KB

Version

1.0.1

Created

Nov 4, 2025

Updated

about 1 month ago

1// ==UserScript==
2// @name		Kiddy Earner Auto Surf
3// @description		Automatically surfs ads on kiddyearner.com
4// @version		1.0.1
5// @match		https://*.kiddyearner.com/*
6// @icon		https://kiddyearner.com/assets/home/img/fav.ico
7// ==/UserScript==
8(function() {
9    'use strict';
10
11    console.log('Kiddy Earner Auto Surf extension loaded');
12
13    // Configuration
14    const CONFIG = {
15        CHECK_INTERVAL: 2000, // Check every 2 seconds
16        AD_CLICK_DELAY: 1000, // Wait 1 second before clicking next ad
17        TIMER_CHECK_INTERVAL: 1000, // Check timer every second
18        MIN_TIMER_VALUE: 1 // Minimum timer value to wait for
19    };
20
21    // State management
22    let isProcessing = false;
23    let currentAdWindow = null;
24
25    // Debounce function to prevent multiple rapid calls
26    function debounce(func, wait) {
27        let timeout;
28        return function executedFunction(...args) {
29            const later = () => {
30                clearTimeout(timeout);
31                func(...args);
32            };
33            clearTimeout(timeout);
34            timeout = setTimeout(later, wait);
35        };
36    }
37
38    // Check if we're on the surf ads listing page
39    function isSurfListingPage() {
40        return window.location.href.includes('/ptc/surf') && 
41               !window.location.href.includes('/ptc/sview/');
42    }
43
44    // Check if we're on an ad viewing page
45    function isAdViewingPage() {
46        return window.location.href.includes('/ptc/sview/');
47    }
48
49    // Get all available ad links on the listing page
50    function getAvailableAds() {
51        const adLinks = document.querySelectorAll('a.view_ads_click[data-adid][data-adtime]');
52        console.log(`Found ${adLinks.length} available ads`);
53        return Array.from(adLinks);
54    }
55
56    // Click the next available ad
57    async function clickNextAd() {
58        if (isProcessing) {
59            console.log('Already processing an ad, skipping...');
60            return;
61        }
62
63        const ads = getAvailableAds();
64        if (ads.length === 0) {
65            console.log('No more ads available to surf');
66            return;
67        }
68
69        isProcessing = true;
70        const firstAd = ads[0];
71        const adId = firstAd.getAttribute('data-adid');
72        const adTime = firstAd.getAttribute('data-adtime');
73        
74        console.log(`Clicking ad ${adId} (${adTime}s duration)`);
75        
76        // Store ad info for later use
77        await GM.setValue('currentAdId', adId);
78        await GM.setValue('currentAdTime', adTime);
79        
80        // Click the ad
81        firstAd.click();
82        
83        // Wait a bit before allowing next click
84        setTimeout(() => {
85            isProcessing = false;
86        }, CONFIG.AD_CLICK_DELAY);
87    }
88
89    // Monitor timer on ad viewing page
90    function monitorAdTimer() {
91        console.log('Monitoring ad timer...');
92        
93        const timerInterval = setInterval(() => {
94            // Check for timer element
95            const timerElement = document.querySelector('.surf_timer');
96            
97            if (timerElement) {
98                const timerValue = parseInt(timerElement.textContent);
99                console.log(`Timer: ${timerValue}s remaining`);
100                
101                if (timerValue <= CONFIG.MIN_TIMER_VALUE) {
102                    console.log('Timer completed, returning to surf page...');
103                    clearInterval(timerInterval);
104                    
105                    // Wait a moment then go back to surf page
106                    setTimeout(() => {
107                        window.location.href = 'https://kiddyearner.com/ptc/surf';
108                    }, 1000);
109                }
110            } else {
111                // Timer element not found, might have completed already
112                console.log('Timer element not found, checking for completion...');
113                
114                // Check if we're still on the ad page or if it redirected
115                if (!isAdViewingPage()) {
116                    console.log('No longer on ad viewing page, stopping timer monitor');
117                    clearInterval(timerInterval);
118                }
119            }
120        }, CONFIG.TIMER_CHECK_INTERVAL);
121    }
122
123    // Handle ad viewing page
124    async function handleAdViewingPage() {
125        console.log('On ad viewing page, starting timer monitor...');
126        
127        // Wait a bit for page to fully load
128        setTimeout(() => {
129            monitorAdTimer();
130        }, 2000);
131    }
132
133    // Handle surf listing page
134    async function handleSurfListingPage() {
135        console.log('On surf listing page');
136        
137        // Check if we just came back from viewing an ad
138        const wasViewingAd = await GM.getValue('wasViewingAd', false);
139        
140        if (wasViewingAd) {
141            console.log('Just completed an ad, waiting before clicking next...');
142            await GM.setValue('wasViewingAd', false);
143            
144            // Wait a bit before clicking next ad
145            setTimeout(() => {
146                clickNextAd();
147            }, CONFIG.AD_CLICK_DELAY * 2);
148        } else {
149            // Start auto-surfing
150            console.log('Starting auto-surf...');
151            setTimeout(() => {
152                clickNextAd();
153            }, CONFIG.AD_CLICK_DELAY);
154        }
155    }
156
157    // Main initialization function
158    async function init() {
159        console.log('Initializing Kiddy Earner Auto Surf...');
160        console.log('Current URL:', window.location.href);
161        
162        if (isSurfListingPage()) {
163            await handleSurfListingPage();
164        } else if (isAdViewingPage()) {
165            await GM.setValue('wasViewingAd', true);
166            await handleAdViewingPage();
167        }
168    }
169
170    // Wait for page to be ready
171    if (document.readyState === 'loading') {
172        document.addEventListener('DOMContentLoaded', init);
173    } else {
174        init();
175    }
176
177})();
Kiddy Earner Auto Surf | Robomonkey