[New] Bitcotasks

Open and close the PTC

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         [New] Bitcotasks
// @namespace    https://greasyfork.org/users/1162863
// @version      1.1
// @description  Open and close the PTC
// @author       Andrewblood
// @match        *://*.bitcotasks.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bitcotasks.com
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        window.focus
// @grant        window.close
// @grant        unsafeWindow
// @license      Copyright Andrewblood
// ==/UserScript==

(function() {
    'use strict';

    // Functions for REAL Click
    function triggerMouseEvent(elm, eventType) {
        let clickEvent = document.createEvent('MouseEvents');
        clickEvent.initEvent(eventType, true, true);
        elm.dispatchEvent(clickEvent);
    }

    function alternativeClick(elm) {
        triggerMouseEvent(elm, "mouseover");
        triggerMouseEvent(elm, "mousedown");
        triggerMouseEvent(elm, "mouseup");
        triggerMouseEvent(elm, "click");
    }

    function specialClick(selector) {
        var interval001 = setInterval(function() {
            // Wähle den Button anhand des Selektors
            var button = document.querySelector(selector);
            // Wähle das CAPTCHA-Element und das Response-Element
            var captchaElement = document.querySelector(".captcha-modal, .g-recaptcha, .h-captcha");
            var captchaResponse = document.querySelector("#g-recaptcha-response, #g-recaptcha-response, #fform > center > div > div > input[type=hidden]");

            // Überprüfe, ob das CAPTCHA-Element vorhanden ist
            if (captchaElement) {
                // Falls das CAPTCHA ausgefüllt ist und der Button sichtbar und aktiv ist, klicke den Button
                if (captchaResponse && captchaResponse.value.length > 0 && button && button.offsetHeight > 0 && !button.hasAttribute('disabled')) {
                    alternativeClick(button);
                    console.log("Element is clicked.");
                    clearInterval(interval001);
                }
            } else {
                // Falls kein CAPTCHA vorhanden ist, überprüfe nur die Sichtbarkeit des Buttons
                if (button && button.offsetHeight > 0 && !button.hasAttribute('disabled')) {
                    alternativeClick(button);
                    console.log("Element is clicked.");
                    clearInterval(interval001);
                }
            }
        }, 500);
    }

    var checkForClaimLimit = ("#faucetContent > h3");
    var loadingSite = ("#main-content > div > h3");

    // ReCaptcha Firewall
    if (window.location.href.includes("firewall")){
        specialClick(".btn.btn-primary.btn-block");
    }

    // Ads Overlay
    if (window.location.href.includes("offerwall")){
        GM_setValue('adActive', false);

        setInterval(function() {
            if (GM_getValue('adActive') === false && document.querySelector(".card.mb-3.mt-1.campaign-block:not(.clicked)")) {
                specialClick(".card.mb-3.mt-1.campaign-block:not(.clicked)");
                GM_setValue('adActive', true);
            } else if (GM_getValue('adActive') === false && !document.querySelector(".card.mb-3.mt-1.campaign-block:not(.clicked)")){
                window.close();
                console.log("Wait for next Ad.");
            }
        }, 3000);

        // Faucet
        specialClick(".btn.btn-lg.btn-primary");
    }

    // PTC ansehem
    if (window.location.href.includes("//lead/")){

        // Open view Ad in new window
        specialClick(".btn-primary.btn");

        // Funktion für das fokusieren des Tabs
        let interval1 = setInterval(function() {
            if (document.title.includes('Claim Reward!')){
                window.focus();
                clearInterval(interval1);
            }
        }, 500);

                // Funktion für das Schließen der Tabs
        var oldFunction = unsafeWindow.open;
        var lastOpenedWindow = null; // Variable zur Speicherung des zuletzt geöffneten Fensters

        function newFunction(url, target) {
            // Setze den Namen des Fensters
            var windowName = (target && target !== "_blank") ? target : "popUpWindow";

            // Öffne das Fenster und speichere die Referenz
            lastOpenedWindow = oldFunction(url, windowName);
            return lastOpenedWindow;
        }

        unsafeWindow.open = newFunction;

        // Schließe das letzte geöffnete Fenster, wenn die Seite verlassen wird
        unsafeWindow.onbeforeunload = function() {
            if (lastOpenedWindow) {
                lastOpenedWindow.close(); // Schließe das Fenster
                lastOpenedWindow = null; // Setze die Referenz zurück
            }
        };

        // Ad nach Captcha schliessen
        setInterval(function() {
            if (document.querySelector("#captcha-result") && document.querySelector("#captcha-result").offsetHeight > 0 && document.querySelector("#captcha-result").innerText == "Verified!"){
                GM_setValue('adActive', false);
                window.close();
            }
        }, 500);

    }

})();