[New] Bitcotasks

Open and close the PTC

目前為 2024-10-03 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);

    }

})();