Greasy Fork

Greasy Fork is available in English.

Auto BTC Rotator with PTC Support

auto faucets

当前为 2024-03-08 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Auto BTC Rotator with PTC Support
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  auto faucets
// @author       vikiweb
// @match        https://btcadspace.com/*
// @match        https://firefaucet.win/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=btcadspace.com
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let sites = [
        {faucetUrl: "https://btcadspace.com/faucet", username: "", password: "", enableFaucet:true, faucetCaptcha:false},
        {faucetUrl: "https://firefaucet.win/faucet/", username: "", password: "",},
    ];

    let sitesMap = [
        {
            websiteUrl:"https://btcadspace.com",
            homePageCheck : "body section.slider",
            claimPopupOpen : ".btn-primary.btn-lg",
            loginCaptchaCheck : true,
            surfSelectors:".card:not(.visited-link)",
            surfStartBtn:".card-body #box .start-btn",
        },
        {
            websiteUrl:"https://firefaucet.win",
            homePageCheck : "form[action='/login']",
            claimPopupOpen : "",
            loginCaptchaCheck : true,
            surfSelectors:".card.ptc-advert-card .watch-btn",
            surfStartBtn:".card-body #box .start-btn",
            additionalFunction : fireFaucet,
        },
    ]


    let check_address = window.location.origin;
    let currentFaucetUrl = new URL(window.location.href);
    let currentOrigin = currentFaucetUrl.origin;
    let currentIndex = sites.findIndex(site => site.faucetUrl.includes(currentOrigin));
    let websiteIndex = sitesMap.findIndex(website => website.websiteUrl.includes(currentOrigin));
    let oldfunction = unsafeWindow.open;
    let windowName = "";
    let interval = 1;

    function movetonext() {
        if (currentIndex === sites.length - 1) {
            currentIndex = 0;
            console.log("All sites visited. Starting from 0 again.");
        } else {
            currentIndex++;
        }
        window.location.href = sites[currentIndex].faucetUrl;
    }

    function checkWindow(params1, params2) {
        console.log(params1 + params2);
        if (!params2 || params2 == "_blank") {
            windowName = "popUpWindow";
        } else {
            windowName = params2;
        }
        console.log("WindowName is::" + windowName);
        return oldfunction(params1, windowName);
    };

    function movetosurf() {
        window.location.href = check_address +'/surf'
    }

    // Check if captcha is checked
    function isCaptchaChecked() {
        return grecaptcha && grecaptcha.getResponse().length !== 0;
    }

    // Check if on faucet page and claim button is disabled
    function isFaucetClaimButtonDisabled(claimPopup) {
        return document.querySelector(claimPopup) && document.querySelector(claimPopup).disabled;
    }

    // Check if on faucet page is fully claimed
    function isFaucetFullyClaimed() {
        return document.querySelector(".notyf-announcer") && document.querySelector(".notyf-announcer").innerText.includes('You reached the maximum')
    }

    function visibleCheck(elm) {
        if(!elm.offsetHeight && !elm.offsetWidth) { return false; }
        if(getComputedStyle(elm).visibility === 'hidden') { return false; }
        return true;
    }

    function websiteLogin(site){
        setInterval(function() {
            if (document.querySelector("#username")) {
                document.querySelector("#username").value = site.username;
            }
            if (document.querySelector("#password")) {
                document.querySelector("#password").value = site.password;
            }
            if (sitesMap[websiteIndex].loginCaptchaCheck){
                if (isCaptchaChecked()) {
                    if (document.querySelector("button[type='submit']")) {
                        document.querySelector("button[type='submit']").click();
                    }
                }
            }else{
                if (document.querySelector("button[type='submit']")) {
                    document.querySelector("button[type='submit']").click();
                }
            }

        }, 6000);
    }

    function fireFaucet(site) {
        if (document.querySelector(sitesMap[websiteIndex].homePageCheck)) {
            websiteLogin(site)
        }

        if(document.querySelector(".dashboard-action-btns")){
            if(document.querySelector("[href='/daily']") && !document.querySelector("[href='/daily']").classList.contains('disabled')){
                document.querySelector("[href='/daily']").click();
            }else if(document.querySelector(".dashboard-action-btns [href='/faucet/']") && !document.querySelector(".dashboard-action-btns [href='/faucet/']").classList.contains('disabled')){
                document.querySelector(".dashboard-action-btns [href='/faucet/']").click();
            }else{
                movetonext()
            }
        }

        if (window.location.href.includes(check_address +'/daily') || window.location.href.includes(check_address +'/faucet/')) {
            setInterval(function() {
                if (document.querySelector("button[type='submit']")) {
                    if (isCaptchaChecked()) {
                        document.querySelector("button[type='submit']").click();
                    }
                }
                if(document.querySelector(".btn.earn-btns") && document.querySelector(".btn.earn-btns").innerText.includes("Continue") || document.querySelector(".btn.earn-btns").innerText.includes("Go Home")){
                    document.querySelector(".btn.earn-btns").click();
                }
            }, 6000);
        }
    }

    // Process current site
    function processSite(site) {
        if (sitesMap[websiteIndex].additionalFunction) {
            sitesMap[websiteIndex].additionalFunction(site);
        }else{
            if(document.querySelector(sitesMap[websiteIndex].homePageCheck) && (window.location.href.includes(check_address))) {
                window.location.replace(check_address + "/login");
            }

            if (window.location.href.includes(check_address +'/login')) {
                console.log(sitesMap[websiteIndex], websiteIndex)
                websiteLogin(site)
            }

            if(window.location.href.includes(check_address +'/account')) {
                if(site.enableFaucet){
                    window.location.replace(check_address +'/faucet');
                }
            }


            if (window.location.href.includes(check_address +'/faucet')) {

                let fauceClick = false;

                setInterval(function() {
                    if (document.querySelector(sitesMap[websiteIndex].claimPopupOpen) && fauceClick === false) {
                        document.querySelector(sitesMap[websiteIndex].claimPopupOpen).click();
                        fauceClick = true;
                    }
                }, 5000);

                setInterval(function() {
                    if(document.querySelector("button[type='submit']")){
                        if(site.faucetCaptcha == true){
                            if (isCaptchaChecked()) {
                                document.querySelector("button[type='submit']").click();
                            }
                        }else{
                            document.querySelector("button[type='submit']").click();
                        }
                    }
                    if(isFaucetFullyClaimed()){
                        movetonext();
                    }
                }, 5000);
                setInterval(function() {
                    if (isFaucetClaimButtonDisabled(sitesMap[websiteIndex].claimPopupOpen) && site.enableSurf == true) {
                        movetosurf()
                    }else if(isFaucetClaimButtonDisabled(sitesMap[websiteIndex].claimPopupOpen)){
                        movetonext()
                    }
                }, interval * 60000);
            }
        }
    }

    // Start processing the first site
    processSite(sites[currentIndex]);
})();