Decrease click at Sakurafile

none

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            Decrease click at Sakurafile
// @name:ja         Sakurafileで楽をするためのスクリプト
// @namespace       http://hogehoge/
// @version         1.*
// @description     none
// @description:ja  多分これが一番楽だと思います(使用は自己責任でお願いします)
// @author          H. Amami
// @match           *://sakurafile.com/*
// @run-at          document-end
// @grant           none
// ==/UserScript==

(function() {
    'use strict';
    if ($(".error_message").length !== 0 || $(".err").length !== 0) {
        console.error("Sakurafile error @ " + location.href);
    } else if (typeof $('#dlink').attr("href") !== "undefined") {
        console.info("Download started @ " + location.href);
        location.href = $('#dlink').attr("href");
    } else if ($('[name="op"]').val() === "download2") {
        var captcha_text = "";
        var $items = $('td>div>span:not(:first):not(:first)');
        $items.sort(function(a, b) {
            return parseInt($(a).css("padding-left")) > parseInt($(b).css("padding-left"));
        });
        $items.each(function() {
            captcha_text += $(this).text();
        });
        while (captcha_text[0] === "0") {
            captcha_text = captcha_text.substr(1);
        }
        $(".captcha_code").val(captcha_text);
        console.info("Solved captcha (" + captcha_text + ") @ " + location.href);
        setInterval(function() {
            if ($('.seconds').text() <= 1) $('form').submit();
        }, 1000);
    } else if ($('[name="op"]').val() === "download1") {
        console.info("Free Download button was clicked @ " + location.href);
        $('[name=method_free]').click();
    }
})();