DropGalaxy Auto Skip

Auto Skip Ads and Auto Download on DropGalaxy

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         DropGalaxy Auto Skip
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Auto Skip Ads and Auto Download on DropGalaxy
// @author       kleptomaniac14
// @match        https://dropgalaxy.com/*
// @match        https://dropgalaxy.co/*
// @match        https://financemonk.net/*
// @icon         https://www.google.com/s2/favicons?domain=dropgalaxy.com
// @grant        none
// @license      GNU GPLv2
// ==/UserScript==

// Setting esversion to 11 to use optional chaining.
/* jshint esversion: 11 */

(function () {
    "use strict";

    // Constants
    const MAX_IDENTIFICATION_RETRIES = 100;

    // Global Variables
    let identificationRetries = 0;

    // Utils
    const log = (message) => console.log(`[DropGalaxy Auto Skip] ${message}`);

    // One Time Setup
    log("DropGalaxy Script Loaded");

    // Page Handlers
    const handlePage1 = () => {
        log("Handling Page 1");

        // Click on Download Button
        const downloadBtn = document.getElementById("method_free");
        downloadBtn.click();
    };

    const handlePage3 = () => {
        log("Handling Page 3");

        // Click on Download Button
        const downloadForm = document.getElementById("dllink");
        const url = downloadForm.action;

        window.location.assign(url);
    };

    const handlePage2 = () => {
        log("Handling Page 2");

        const falseDownloadBtn = document.getElementById("downloadbtn");
        const tokenStatus = document.getElementById("tokennstatus");

        // Keep clicking until enabled
        const downloadIntervalId = setInterval(() => {
            if (
                tokenStatus.innerText === "ready!" &&
                falseDownloadBtn.disabled === false
            ) {
                log("Download Button Enabled, submitting form");
                // downloadBtn.click();
                document.getElementById("ff1").submit();
                clearInterval(downloadIntervalId);
            }
        }, 500);
    };

    const handlePage = (pageWatcherIntervalId) => {
        const page1Identifier = document.getElementById("method_free");
        const page2Identifier = document.getElementById("countdown");
        const page3Identifier = document.getElementById("url");

        const adblockPageIdentifier = document.querySelector(
            "body > div.container.pt-5.page.message > div > div > div"
        );
        const isAdblockPage =
            adblockPageIdentifier?.innerText === "\nAdblock Detected!";

        // If page is recognized, clear the interval to stop checking
        if (
            pageWatcherIntervalId &&
            (page1Identifier ||
                page2Identifier ||
                page3Identifier ||
                isAdblockPage)
        ) {
            log("Page Identified, stopping page watcher");
            clearInterval(pageWatcherIntervalId);
            // identificationRetries = 0;
            // no need to reset retries, as it will be reset on next page load
        }

        if (page1Identifier) {
            handlePage1();
        } else if (page2Identifier) {
            handlePage2();
        } else if (page3Identifier) {
            handlePage3();
        } else if (isAdblockPage) {
            // handleAdblockPage();
            // Not implemented
        } else if (MAX_IDENTIFICATION_RETRIES > identificationRetries) {
            log("Unknown Page or Waiting for identification");
            identificationRetries++;
        }
    };

    // Keep checking the page as soon as it loads
    let intervalId = setInterval(() => {
        handlePage(intervalId);
    }, 500);
})();