CursosDev Auto Gather Coupon

Script to auto gather coupns from CursosDev

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         CursosDev Auto Gather Coupon
// @namespace    http://tampermonkey.net/
// @version      0.1.0.5
// @description  Script to auto gather coupns from CursosDev
// @author       0x01x02x03
// @match        https://www.cursosdev.com/coupons-udemy/*
// @match        https://www.discudemy.com/*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=cursosdev.com
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function closeTab(){
        window.open('','_self').close();
    }

    function autoGather() {
        let couponButton = document.body.querySelector('html > body > main > div:nth-of-type(1) > main > div > div > div:nth-of-type(1) > article > div:nth-of-type(1) > section:nth-of-type(5) > div > div:nth-of-type(3) > div > div:nth-of-type(2) > div:nth-of-type(2) > a');
        let couponButtonTwo = document.body.querySelector('html > body > div:nth-of-type(2) > div > section > div:nth-of-type(5) > div > a');
        let couponButtonTwoLink = document.body.querySelector('#couponLink');
        if(couponButton != null){
            closeTab();
            couponButton.click();
        }
        else if(couponButtonTwo != null){
            couponButtonTwo.click();
            if(couponButtonTwoLink != null){
                setTimeout(closeTab,5000);
                couponButtonTwoLink.click();
            }
        }
    }

    setTimeout(autoGather, 5000);
})();