dbr.ee: direct download

creates a direct download button on dbr.ee

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        dbr.ee: direct download
// @namespace   mailto:[email protected]
// @locale      en
// @include     *dbr.ee*
// @version     1.4
// @run-at      document-start
// @grant       none
// @description creates a direct download button on dbr.ee
// ==/UserScript==

(function()
{
'use strict';

function in_array(needle, haystack)
{
    var length = haystack.length;
    for(var i = 0; i < length; i++)
    {
        if(haystack[i] == needle) return true;
    }
    return false;
}

var fileid = window.location.href.split("/").slice(-1)[0];
var ignoreurls =
[
    "",
    "help",
    "dmca",
];

if(!in_array(fileid, ignoreurls) && fileid.length == 4)
{
    document.addEventListener("DOMContentLoaded", waitForDLButton);
}

function doEverything(btn)
{
    var newbtnform = document.createElement("form");
    newbtnform.setAttribute("class", "button_to");
    newbtnform.setAttribute("method", "get");
    newbtnform.setAttribute("action", "/"+fileid+"/d");

    var newbtnspan = document.createElement("span");
    newbtnspan.setAttribute("class", "icon-download");

    var newbtn = document.createElement("button");
    newbtn.setAttribute("class", "btn btn--block");
    newbtn.setAttribute("title", "Direct Download");
    newbtn.setAttribute("data-disable-with", "Downloading...");
    newbtn.setAttribute("type", "submit");
    newbtn.innerHTML = "&nbsp;DOWNLOAD";

    newbtn.insertBefore(newbtnspan, newbtn.childNodes[0]);
    newbtnform.appendChild(newbtn);

    var btnparent = btn.parentElement;
    btn.remove();
    btnparent.appendChild(newbtnform);
}

function waitForDLButton()
{
    var spinner = document.getElementsByClassName("spinner");

    if(spinner.length > 0)
    {
        doEverything(spinner[0].parentElement);
    }
    else
    {
        setTimeout(waitForDLButton, 100);
    }
}
})();