DataVaults - Auto download

Takes you to the actual download, auto-fills captcha, waits for timer, then auto-downloads the file.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         DataVaults - Auto download
// @version      05-18-26
// @description  Takes you to the actual download, auto-fills captcha, waits for timer, then auto-downloads the file.
// @author       WATCH_TEXHNOLYZE
// @match        https://datavaults.co/*
// @grant        none
// @namespace https://greasyfork.org/users/1122886
// ==/UserScript==

(function() {
'use strict';
function fillCaptcha() {
    const d=document.querySelector('td div[style*="background"]');
    if(!d) return;
    const s=d.querySelectorAll('span[style*="padding-left"]');
    if(!s.length) return;
    const a=[];
    s.forEach(e=>{
        const t=e.textContent.trim(),
              m=e.getAttribute('style').match(/padding-left\s*:\s*(\d+)px/);
        if(m && t.length===1) a.push({digit:t, pos:+m[1]});
    });
    a.sort((x,y)=> x.pos-y.pos);
    const c=a.map(x=>x.digit).join(''),
          i=document.querySelector('input.captcha_code[name="code"]');
    if(i&&c) i.value=c;
}
function clickIntermediate() {
    const b=document.getElementById('original');
    if(b) b.click();
}
function waitAndSubmit() {
    const b=document.getElementById('downloadbtn');
    if(!b) return;
    const t=setInterval(()=>{
        if(!b.disabled) {
            clearInterval(t);
            const f=document.querySelector('form[name="F1"]')||document.forms[0];
            if(f) f.submit();
        }
    },500);
}
function handle() {
    const i=document.querySelector('input.captcha_code[name="code"]');
    if(i) { fillCaptcha(); waitAndSubmit(); }
    else if(document.getElementById('original')) clickIntermediate();
}
handle();
new MutationObserver(handle).observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:['style','class']});
})();