Greasy Fork

自动下载

自动下载助手

目前为 2023-08-08 提交的版本。查看 最新版本

// ==UserScript==
// @name         自动下载
// @namespace    http://www.nite07.com/
// @version      0.1
// @description  自动下载助手
// @author       Nite07
// @match        https://oxy.st/d/*
// @match        https://uploadrar.com/*
// @grant        none
// @run-at document-end
// @license MIT
// ==/UserScript==

(() => {
	console.log('开始获取下载链接');
	switch (window.location.host) {
		case 'oxy.st':
			oxy();
			break;
		case 'uploadrar.com':
			uploadrar();
			break;
	}
})();

function oxy() {
	let linkElem = document.querySelector('div[data-batch_id="1"]');
	if (linkElem) {
		let link = linkElem.getAttribute('data-source_url');
		console.log('下载链接: ' + link);
		window.location.href = link;
	}
}

function uploadrar() {
	let freeDownloadBtn = document.querySelector('input[name="method_free"]');
	let createDownloadLinkBtn = document.querySelector('button#downloadbtn');
	let downloadBtn = document.querySelector('span#direct_link>a');
	if (freeDownloadBtn) {
		freeDownloadBtn.click();
	}
	if (createDownloadLinkBtn) {
		createDownloadLinkBtn.click();
	}
	if (downloadBtn) {
		downloadBtn.click();
	}
}