Greasy Fork

Greasy Fork is available in English.

[New] Coinpayu.com

Open and close Framed and Frameless Ads

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

在您安装前,Greasy Fork 希望您知道此脚本声明其包含了一些负面功能。这些功能也许会使脚本作者获利,而不能给您带来任何直接的金钱收益。

作者可从这份脚本获得佣金,例如通过修改链接地址或提供优惠券代码以包含推荐或附属代码。 脚本作者的说明: Referral-Link is in this Script integrated.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         [New] Coinpayu.com
// @namespace    http://greasyfork.icu/users/1162863
// @version      3.0.1
// @description  Open and close Framed and Frameless Ads
// @author       Andrewblood
// @match        *://*.coinpayu.com/*
// @exclude      *://*.coinpayu.com/login
// @icon         https://www.google.com/s2/favicons?sz=64&domain=coinpayu.com
// @grant        window.close
// @antifeature  referral-link     Referral-Link is in this Script integrated.
// @license      Copyright Andrewblood
// ==/UserScript==

(function() {
    'use strict';


    var oldfunction = unsafeWindow.open;
    var windowName = "";
    function newFunction(params1, params2) {
        if (!params2 || params2 == "_blank") {
            windowName = "popUpWindow";
        } else {
            windowName = params2;
        }
        return oldfunction(params1, windowName);
    };

    unsafeWindow.open = newFunction;
    unsafeWindow.onbeforeunload = function() {
        unsafeWindow.open('', windowName).close();
    };


    if (window.location.href.includes("register")) {
        if (!window.location.href.includes("Andrewblood")) {
            window.location.href = "https://www.coinpayu.com/register?r=Andrewblood";
        }
    }

    setTimeout(function() {
        document.querySelector("#toViewAds").click();
        setTimeout(function() {
            document.querySelector("#viewads > div.nav-head.dashboard-actived > p").click();
        }, 500);
    }, 1000 * 2);

    setTimeout(function() {
        var elements = document.querySelectorAll('.clearfix.ags-list-box:not(.gray-all.clearfix.ags-list-box)');
        if (elements.length > 0) {
            var firstElement = elements[0].querySelector('.text-overflow.ags-description > span');
            var timeElement = elements[0].querySelector('.ags-detail-time span');
            var urlElement = elements[0].querySelector('.text-overflow.ags-description');
            var url = urlElement.getAttribute('title');
            var time = parseInt(timeElement.textContent);

            console.log('Open ' + url + ' for ' + time + ' seconds.');
            urlElement.removeAttribute('title');

            if (firstElement) {
                firstElement.click();

                unsafeWindow.open('', windowName).close();

                var interval = setInterval(function() {
                    var alertElement = document.querySelector(".alert-div.alert-green");
                    if (alertElement) {
                        clearInterval(interval);
                        window.location.reload();
                    }
                }, 1000);
            }
        } else {
            document.querySelector("#viewads > div:nth-child(2) > p").click();
        }
    }, 1000 * 4);



    setTimeout(function() {
        if (document.querySelector("#app > div > div.coinpayu-dashboard-content > div.main-panel > div > div > h6").innerText.includes("Framed Ads")) {
            var elements = document.querySelectorAll('.clearfix.ags-list-box:not(.gray-all.clearfix.ags-list-box)');
            if (elements.length > 0) {
                var firstElement = elements[0].querySelector('.text-overflow.ags-description > span');
                var timeElement = elements[0].querySelector('.ags-detail-time span');
                var url = elements[0].querySelector('.text-overflow.ags-description').getAttribute('title');
                var time = parseInt(timeElement.textContent);
                console.log('Open ' + url + ' for ' + time + 'seconds.');
                if (firstElement) {
                    firstElement.click();
                    var interval = setInterval(function() {
                        var alertElement = document.querySelector(".alert-div.alert-green");
                        if (alertElement) {
                            clearInterval(interval);
                            setTimeout(function() {
                                unsafeWindow.open('', windowName).close();
                                window.location.reload();
                            }, 1000);
                        }
                    }, 1000);
                }
            } else {
                window.close();
            }
        }
    }, 1000 * 6);


    if (window.location.href.includes("coinpayu.com/dashboard/view_active?id=")) {
        var intervalId = setInterval(function() {
            var waittime = document.querySelector("#app > div > div > div > div > div");
            if (waittime && waittime.style.width === "100%") {
                clearInterval(intervalId);
                setTimeout(function() {
                    window.close();
                }, 500);
            }
        }, 100);
    }

})();