Easy offline | 一键离线下载

一键自动将磁链、bt种子或其他下载资源离线下载至网盘 | Easy stream torrents or videos from cloud storage

目前為 2016-10-10 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Easy offline | 一键离线下载
// @namespace    http://tampermonkey.net/
// @version      1.0.8
// @description  一键自动将磁链、bt种子或其他下载资源离线下载至网盘 | Easy stream torrents or videos from cloud storage
// @author       Hoothin
// @mail         [email protected]
// @include      http*://pan.baidu.com/*
// @include      http://115.com/*
// @include      https://www.furk.net/*
// @include      https://www.seedr.cc/*
// @include      http*://*/*
// @grant        GM_setValue
// @grant        GM_getValue
// @require      http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js
// ==/UserScript==

var enableUrl = 'a[href^="magnet"],[href^="ed2k://|file"],[href$=".torrent"],[href$=".mp4"],[href$=".rar"],[href$=".7z"],[href$=".zip"],[href$=".rmvb"],[href$=".mkv"],[href$=".avi"],[href$=".iso"]';
var disableUrl=[".torrentkitty.","bt.box.n0808.com"];
var lang = navigator.appName=="Netscape"?navigator.language:navigator.userLanguage;
var i18n={};
switch (lang){
    case "zh-CN":
        i18n={
            yyw:"115网盘",
            baidu:"百度网盘",
            furk:"Furk网盘",
            seedr:"Seedr网盘"
        };
        break;
    default:
        i18n={
            yyw:"115",
            baidu:"BaiduPan",
            furk:"Furk",
            seedr:"Seedr"
        };
        break;
}
function include(Things,obj) {
    for (var i = Things.length - 1; i >= 0; i--) {
        if ($(Things[i]).attr('href')===$(obj).attr('href')){
            return true;
        }
    }
}

function setCss(){
    $('head').append('<style>a.whx-a{ display:inline-block;margin-left:5px;height:25px;width:25px;background-size:20px;border-radius:50%;vertical-align:middle;transition:margin-top 0.5s ease;}</style>');
}

function getAllEnableUrl() {
    var rawnodes = $(enableUrl).get();
    var nodes = [];
    var i;
    var curNode;
    if(rawnodes.length>0){
        for (i = 0; i <rawnodes.length; i++) {
            var disable = false;
            curNode = rawnodes[i];
            for(var j = 0; j < disableUrl.length; j++){
                var temp = disableUrl[j];
                if($(curNode)[0].href.indexOf(temp)!=-1){
                    disable = true;
                    break;
                }
            }
            if(disable)continue;
            if(!include(nodes,curNode)){
                nodes.push(curNode);
            }
        }
    }
    if(nodes.length>0){
        var codeList = [];
        var listLen = 0;
        listLen = nodes.length;
        setCss();
        if (listLen !== 0) {
            for (i = 0; i < listLen; i++) {
                curNode = nodes[i];
                var url = $(curNode)[0].href;
                var cloneNodes=[];
                var parentDiv=$("<div style='display:none;position:fixed;'></div>");
                $("body").append(parentDiv);
                parentDiv.mouseleave(function(e){
                    parentDiv.css("display","none");
                    for(var clone of cloneNodes){
                        clone.css("margin-top","0px");
                    }
                });
                for(var x=0;x<5;x++){
                    var clone=$(curNode).clone();
                    clone.addClass('whx-a').css("outline","none").css("background-position","center").css("background-repeat","no-repeat").css("background-image",'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAMAAADzN3VRAAAARVBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADc6ur3AAAAFnRSTlMAYM5vMOA/ENGegK2olI6G1b97Z0sXENA+jAAAAKFJREFUKM+FklkSxCAIRHFfss3K/Y86iQSDVqzpH7FfgQpCVfAmGx+gl9JI0qrxrcNLzooEbKUG4EKWdkCiDRV0N0RTrZ5wvdgTTgp4SzCAHxAPZkAM5GOJWuuT7FE5OVPOBFLTYb3Oc2YB5uJ8+G6pgkTGt74ntcCJHiwFLHw10Tdc93jlGXGvSRtsHNpuPs+/o1ODfxAtSL0f7HPC+L/9AF60G3QxO1UaAAAAAElFTkSuQmCC")').empty();
                    if(x!==4){
                        parentDiv.prepend(clone);
                        clone.css("position","absolute");
                        clone.css("margin-left","0px");
                        clone.css("margin-top","0px");
                        clone.attr("target","_blank").attr("url",url).click(function (event) {GM_setValue("url",$(event.target).attr("url"));});
                    }
                    cloneNodes.push(clone);
                }
                cloneNodes[4].mouseover(function(e){
                    parentDiv.css("display","block");
                    var basePos=cloneNodes[4].offset();
                    parentDiv.offset({top:basePos.top,left:basePos.left});
                    for(var x=0;x<4;x++){
                        cloneNodes[x].css("margin-top",-x*25+"px");
                    }
                });
                cloneNodes[4].css("background-color","#e1e1e1");
                cloneNodes[3].css("background-color","#5e5eff").attr("title",i18n.yyw ).attr("href", "http://115.com/?tab=offline&mode=wangpan");
                cloneNodes[2].css("background-color","#3BEBFF").attr("title",i18n.furk ).attr("href", "https://www.furk.net/users/files/add");
                cloneNodes[1].css("background-color","#F44336").attr("title",i18n.seedr ).attr("href", "https://www.seedr.cc/files");
                cloneNodes[0].css("background-color","#e1e1e1").attr("title",i18n.baidu ).attr("href", "http://pan.baidu.com/disk/home");
                $(curNode).after(cloneNodes[4]);
            }
        }
    }
}

var i=0;
var t=window.setInterval(function() {
    var curlink;
    if (location.href.indexOf("furk.net/users/files/add") != -1){
        window.clearInterval(t);
        curlink = GM_getValue('url');
        if(curlink){
            setTimeout(function() {
                $('#url').val(curlink);
                GM_setValue('url', '');
                $(":submit[value='Add download']").click();
            }, 500);
        }
    }else if(location.href.indexOf("seedr.cc/files") != -1){
        if($('#upload-button').css("display") != "none"){
            window.clearInterval(t);
            curlink = GM_getValue('url');
            if(curlink){
                setTimeout(function() {
                    $(':text[name="torrent"]').val(curlink);
                    GM_setValue('url', '');
                    $('#upload-button').click();
                }, 500);
            }
        }
    }else if(location.href.indexOf("pan.baidu.com/disk/home") != -1){
        window.clearInterval(t);
        curlink = GM_getValue('url');
        if(curlink){
            document.querySelector('.g-button[data-button-id=b13]').click();
            var bsi = setInterval(function() {
                var newTaskBtn = document.querySelector('#_disk_id_2');
                if(newTaskBtn){
                    clearInterval(bsi);
                    newTaskBtn.click();
                    setTimeout(function() {
                        document.querySelector('#share-offline-link').value = curlink;
                        document.querySelector('.g-button[data-button-id=b63]').click();
                    }, 500);
                }
            }, 500);
            GM_setValue('url', '');
        }
    }else if(location.href.indexOf("115.com/?tab=offline&mode=wangpan") != -1){
        window.clearInterval(t);
        curlink = GM_getValue('url');
        if(curlink){
            var rsc = setInterval(function() {
                if (document.readyState == 'complete') {
                    clearInterval(rsc);
                    setTimeout(function() {
                        Core['OFFL5Plug'].OpenLink();
                        setTimeout(function() {
                            $('#js_offline_new_add').val(curlink);
                        }, 300);
                    }, 1000);
                }
            }, 400);
            GM_setValue('url', '');
        }
    }else if((i===0 && $(enableUrl).length>0)||i>20){
        window.clearInterval(t);
        getAllEnableUrl();
    }else{
        i++;
    }
}, 500);