[Premium] adBTC by Andrewblood

Make all Ads and Shortlinks.

// ==UserScript==
// @name         [Premium] adBTC by Andrewblood
// @namespace    https://greasyfork.org/users/1162863
// @version      1.1.0
// @description  Make all Ads and Shortlinks.
// @author       Andrewblood
// @match        *://*.adbtc.top/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=adbtc.top
// @grant        window.focus
// @grant        window.close
// @grant        unsafeWindow
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_deleteValue
// @antifeature  referral-link     Referral-Link is in this Script integrated.
// @license      Copyright Andrewblood
// ==/UserScript==

(function() {
    'use strict';

    const titles = [
        'Just a moment',
        '稍等片刻',
        'Een ogenblik',
        'Un instant',
        'Nur einen Moment',
        'Un momento',
        'Um momento',
        'Bir an'
    ];

    if (titles.some(title => document.title.includes(title))) {
        console.log('Cloudflare-Challenge-Seite erkannt. Skript wird gestoppt.');
        return; // Beendet die Ausführung des Skripts
    }

    // --- Hier beginnt dein eigentliches Skript ---
    console.log('Seite ist OK. Skript läuft.');

    if (window.location.href === "https://adbtc.top/") window.location.replace("https://adbtc.top/r/l/3828777");

    clickByText("LOG IN");

    if (window.location.href.includes("index")){
        clickByText("START EARNING");
        clickByText("SURF ADS");
    }

    if (window.location.href.includes("surf")){

        const interval = setInterval(function() {
            const captchaElement = document.querySelector(".cf-turnstile")
            const captchaResponse = document.querySelector('[name="cf-turnstile-response"]');
            const button = document.querySelector(".btn");
            if (captchaElement && captchaElement.offsetHeight > 0) {
                captchaElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
                if (button && button.offsetHeight > 0 && !button.hasAttribute('disabled') && !button.disabled) {
                    if (captchaResponse && captchaResponse.value.length > 0) {
                        clearInterval(interval);
                        console.log("Captcha ausgefüllt gefunden. Klicke: " + button);
                        button.click();
                    } else {
                        console.log("Captcha gefunden, warte auf Lösung...");
                    }
                }
            }
            if (document.title.includes("You earned")){
                clearInterval(interval);
                window.focus();
            }
            if (document.title.includes("You closed")){
                clearInterval(interval);
                window.focus();
                if (unsafeWindow.myWindow) {
                    unsafeWindow.myWindow.close();
                }
                if (unsafeWindow.coinwin) {
                    var tmp = unsafeWindow.coinwin;
                    unsafeWindow.coinwin = {};
                    tmp.close();
                }
                clickByText("SKIP");
            }
        }, 1000);
        clickByText("SENDEN");
        clickByText("0PEN");
        clickByText("OPЕN");


        if (document.querySelector("body > div.row.bodypad > div.col.s12.m9 > div:nth-child(3) > p.flow-text") && document.querySelector("body > div.row.bodypad > div.col.s12.m9 > div:nth-child(3) > p.flow-text").innerText == 'You have watched all the available ads for now. Please, come back later, new sites are adding several times a day. Users with higher rating have more ads available.') {
            if (window.location.href.includes("/surf/browse/")) {
                clickByText("Surf ads USDT");
            }
            if (window.location.href.includes("/surfusd/browse/")) {
                clickByText("Surf ads ₽");
            }
            if (window.location.href.includes("/surfiat/browse/")) {
                let round = GM_getValue('roundNumber', 0);
                round++;
                console.log("Aktueller Durchlauf: " + round);

                if (round <= 5) {
                    GM_setValue('roundNumber', round);
                    clickByText("Video ads");
                    if (round === 5) {
                        console.log("Fünfter Durchlauf abgeschlossen. Das Skript wird beim nächsten Mal in diesem Block stoppen.");
                    }
                } else {
                    console.log("Maximale Anzahl von 10 Durchläufen erreicht. Stoppe Skript und setze Zähler zurück.");
                    GM_deleteValue('roundNumber');
                    window.close();
                }
            }
        }
    }

    if (window.location.href.includes("/video/inf")){
        if (document.querySelector("#pre > p.flow-text") && document.querySelector("#pre > p.flow-text").innerText == 'You have watched all the available ads for now. Please, come back later, new sites are adding several times a day. Users with higher rating have more ads available.'){
            clickByText("Shortlinks");
        }
    }

    if (window.location.href.includes("/shortlink")){
        clickByText("VISIT");
        if (document.querySelectorAll("span.grey-text.right")[0].innerText.includes("Wait") && document.querySelectorAll("span.grey-text.right")[1].innerText.includes("Wait")){
            clickByText("Surf ads\ncomputer");
        }
    }

    if (window.location.href.includes("/shortlink/check")){
        clickByText("Shortlinks");
    }

    if (window.location.href.includes("autosurf/session")){
        setTimeout(() => {
            window.location.reload();
        }, 1000*60*5);
    }

    function clickByText(text) {
        const interval = setInterval(function() {
            const clickableElements = document.querySelectorAll('button, a, input[type="button"], input[type="submit"]');
            for (let button of clickableElements) {
                if (button && button.innerText && button.innerText.includes(text) && button.offsetHeight > 0 && !button.hasAttribute('disabled') && !button.disabled) {
                    console.log("Klicke: " + button.innerText + button);
                    clearInterval(interval);
                    button.click();
                    return;
                }
            }
        }, 1000);
    }

    window.onbeforeunload = function() {
        if (unsafeWindow.myWindow) {
            unsafeWindow.myWindow.close();
        }
        if (unsafeWindow.coinwin) {
            var tmp = unsafeWindow.coinwin;
            unsafeWindow.coinwin = {};
            tmp.close();
        }
    };

})();