Last active
November 11, 2018 18:00
-
-
Save mirka/3aa99cc04fefe7034288 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name AutoDownloader JP | |
// @description 規約同意ページ等を飛ばしてファイルを自動ダウンロード (対応サイト: Firestorage, 宅ふぁいる便, FilePost, GigaFile便, おくりん坊, データ便) | |
// @author mirka | |
// @include http://firestorage.jp/download/* | |
// @include http://firestorage.jp/index.cgi* | |
// @include http://xfs.jp/* | |
// @include https://www.filesend.to/filedn/* | |
// @include https://taku.filesend.to/* | |
// @include https://free.filesend.to/* | |
// @include https://*.gigafile.nu/* | |
// @include http://file-post.net/ja/fp*/d* | |
// @include https://okurin.bitpark.co.jp/download.php?* | |
// @include https://www.datadeliver.net/receiver/file_box.do?* | |
// @include https://www.takufile.com/receive/* | |
// @namespace http://jaguchi.com | |
// @version 1.1.12 | |
// ==/UserScript== | |
(function() { | |
// Utility: Run a function for each array element at time intervals | |
function runAtIntervalForEach(arr, func) { | |
var interval_msec = 1000; /* interval for downloading multiple files */ | |
var delay_msec = 0; | |
for (var i = 0; i < arr.length; i++) { | |
setTimeout(func, delay_msec, arr[i]); | |
delay_msec += interval_msec; | |
} | |
} | |
// Firestorage.jp | |
// Redirect shortened urls (xfs.jp) | |
function redirectXfs() { | |
var dl_link_regex = /http:\/\/firestorage\.jp\/download\/.+/; | |
for (var i = 0; i < document.links.length; i++) { | |
if (document.links[i].href.match(dl_link_regex)) { | |
window.location = document.links[i].href; | |
} | |
} | |
} | |
function dlFirestorage() { | |
var dl_link = document.getElementById("downloadlink"); | |
// On download page | |
if (dl_link) { | |
dl_link.click(); | |
return; | |
} | |
// On one-time URL page | |
if (document.body.textContent.match("ダウンロードワンタイムURLのご案内")) { | |
redirectXfs(); | |
} | |
// On interstitial page | |
for (var i = 0; i < document.links.length; i++) { | |
if (document.links[i].textContent == "ダウンロードページを表示する") { | |
window.location = document.links[i].href; | |
} | |
} | |
} | |
// 宅ふぁいる便 & 宅ふぁいる便プレミアム | |
function dlTakuFileBin() { | |
var dl_btns, batch_dl_btn; | |
var free_batch_btn, premium_batch_btn; | |
// Agree to terms | |
if (window.location.pathname == "/filedn/infoindex.phtml" /* Premium */ || | |
window.location.pathname == "/filedn_infoindex" /* Free */) { | |
document.forms.r_box.submit(); | |
return; | |
} | |
// Download | |
if (window.location.pathname == "/filedn/index.phtml" /* Premium */ || | |
window.location.pathname == "/filedn_download" /* Free */) { | |
free_batch_btn = document.querySelector("td a img[onclick*='matometedownload']"); | |
premium_batch_btn = document.querySelector("td a[href*='matomete'] img"); | |
batch_dl_btn = free_batch_btn ? free_batch_btn : premium_batch_btn; | |
if (batch_dl_btn) { | |
batch_dl_btn.click(); | |
} else { | |
dl_btns = document.querySelectorAll("td.downloadBtn a img"); | |
runAtIntervalForEach(dl_btns, function (dl_btn) { dl_btn.click(); }); | |
} | |
} | |
} | |
// 宅ふぁいる便ビジネスプラス | |
function dlTakuFileBinPlus() { | |
var doc_imgs; | |
var dl_imgs = []; | |
if (window.location.pathname == "/receive/index.phtml") { | |
document.forms.r_box.submit(); /* agree to terms */ | |
} else if (window.location.pathname == "/receive/download.phtml") { | |
doc_imgs = document.images; | |
for (var i = 0; i < doc_imgs.length; i++) { | |
if (/btn_download.jpg/.test(doc_imgs[i].src)) { | |
dl_imgs.push(doc_imgs[i]); | |
} | |
} | |
runAtIntervalForEach(dl_imgs, function (dl_img) { dl_img.parentNode.click(); }); | |
} | |
} | |
// FilePost | |
function dlFilePost() { | |
var dl_btns = document.querySelectorAll("input[alt='ダウンロード']"); | |
runAtIntervalForEach(dl_btns, function (dl_btn) { dl_btn.click(); }); | |
} | |
// GigaFile便 | |
function dlGigaFile() { | |
document.getElementsByClassName("download_panel_btn_dl")[0].click(); | |
} | |
// おくりん坊 | |
function dlOkurin() { | |
var dl_btns = document.querySelectorAll("input[value='ダウンロード開始']"); | |
runAtIntervalForEach(dl_btns, function (dl_btn) { dl_btn.click(); }); | |
} | |
// データ便 | |
function dlDataDeliver() { | |
var possible_links; | |
var dl_links = []; | |
if (document.getElementsByClassName("kiyaku_bg")[0]) { /* terms page */ | |
document.getElementById("agree").checked = true; | |
document.forms[0].submit(); | |
} else { | |
possible_links = document.querySelectorAll("p a"); | |
for (var i = 0; i < possible_links.length; i++) { | |
if (/\/receiver\/download\.do.+/.test(possible_links[i].href)) { | |
dl_links.push(possible_links[i]); | |
} | |
} | |
runAtIntervalForEach(dl_links, function (link) { link.click(); }); | |
} | |
} | |
/* --- Detect site --- */ | |
if (/gigafile/.test(window.location.hostname)) { // GigaFile便 | |
dlGigaFile(); | |
} else { | |
switch (window.location.hostname) { | |
case "firestorage.jp": // Firestorage.jp | |
dlFirestorage(); | |
break; | |
case "xfs.jp": // Firestorage.jp (短縮URL) | |
redirectXfs(); | |
break; | |
case "free.filesend.to": // 宅ふぁいる便 | |
case "www.filesend.to": // 宅ふぁいる便プレミアム | |
case "taku.filesend.to": // 宅ふぁいる便プレミアム (混雑時) | |
dlTakuFileBin(); | |
break; | |
case "www.takufile.com": // 宅ふぁいる便ビジネスプラス | |
dlTakuFileBinPlus(); | |
break; | |
case "file-post.net": // FilePost | |
dlFilePost(); | |
break; | |
case "okurin.bitpark.co.jp": // おくりん坊 | |
dlOkurin(); | |
break; | |
case "www.datadeliver.net": // データ便 | |
dlDataDeliver(); | |
break; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment