Greasy Fork 还支持 简体中文。

dbr.ee: instant download

creates a direct download button on dbr.ee and clicks it

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        dbr.ee: instant 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 and clicks it
// ==/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);

    newbtnform.submit();
}

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

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