UploadrAr Auto Downloader

Automatically clicks download links for UploadrAr

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         UploadrAr Auto Downloader
// @description  Automatically clicks download links for UploadrAr
// @author       Magic <[email protected]>
// @license      MIT
// @namespace    https://github.com/magicoflolis/userscriptrepo/tree/master/UploadrAr
// @homepageURL  https://github.com/magicoflolis/userscriptrepo/tree/master/UploadrAr
// @supportURL   https://github.com/magicoflolis/userscriptrepo/issues/new
// @icon         https://uploadrar.com/uploadrar_style/images/favicon.png
// @match        https://uploadrar.com/*
// @exclude      https://uploadrar.com/?op=*
// @exclude      https://uploadrar.com/make_money.html
// @exclude      https://uploadrar.com/pages/*
// @version      1.1
// @grant        none
// ==/UserScript==

// Options
let Version = "free", // free (default) / premium
fullAutoDownload = true, // true (default) / false
afterDelay = 0; // 0 (default) / any #

// Userscript Code
(() => {
  try {
    const delay = (ms) => {
      return new Promise(resolve => setTimeout(resolve, ms));
    },
    qs = async element => {
      while (document.querySelector(element) === null) {
        await new Promise(resolve => requestAnimationFrame(resolve));
      }
      return (afterDelay !== 0) ? delay(afterDelay).then(() => document.querySelector(element)) : document.querySelector(element);
    };
    let firstSel,secondSel;
    (Version !== "free") ? (
      firstSel = "input.xfs-premium-download",
      secondSel = "input.mngez-premium-download"
      ) : (
        firstSel = "input.xfs-free-download",
        secondSel = "input.mngez-free-download"
        )
    if(fullAutoDownload) {
      qs(firstSel).then(btn => {
        btn.click();
      });
      qs(secondSel).then(btn => {
        btn.click();
      });
    } else {
      qs(secondSel).then(btn => {
        btn.click();
      });
    };
    qs("span#direct_link > a").then(link => {
      window.open(link.href, "_blank");
    });
  } catch (e) {
    console.log("[%cUAD%c] %cERROR","color: rgb(29, 155, 240);","","color: rgb(249, 24, 128);",e)
  }
})();