Decrease click at Sakurafile

none

As of 2017-05-14. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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();
    }
})();