Easy offline

Easy stream torrents or videos from cloud storage

Tính đến 12-10-2016. Xem phiên bản mới nhất.

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

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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         Easy offline
// @name:zh-CN   一键离线下载
// @name:zh-TW   一鍵離綫下載
// @description  Easy stream torrents or videos from cloud storage
// @description:zh-CN 一键自动将磁链、bt种子或其他下载资源离线下载至网盘
// @description:zh-TW 一鍵自動將磁鏈、bt種子或其他下載資源離綫下載至網槃
// @namespace    http://tampermonkey.net/
// @version      1.0.13
// @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;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,x;
    var curNode;
    var parentDiv=$("<div style='display:none;position:fixed;'></div>");
    var offUrl;
    var offNodes=[];
    for(x=0;x<4;x++){
        var offNode=$("<a></a>");
        offNode.addClass('whx-a').css("outline","none").css("position","absolute").css("margin-top","0px").css("margin-left","0px").css("padding","0px").css("height","25px").css("width","25px").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();
        offNode.attr("target","_blank").click(function (event) {GM_setValue("url",offUrl);});
        switch(x){
            case 0:
                offNode.css("background-color","#e1e1e1").attr("title",i18n.baidu ).attr("href", "http://pan.baidu.com/disk/home");
                break;
            case 1:
                offNode.css("background-color","#F44336").attr("title",i18n.seedr ).attr("href", "https://www.seedr.cc/files");
                break;
            case 2:
                offNode.css("background-color","#3BEBFF").attr("title",i18n.furk ).attr("href", "https://www.furk.net/users/files/add");
                break;
            case 3:
                offNode.css("background-color","#5e5eff").attr("title",i18n.yyw ).attr("href", "http://115.com/?tab=offline&mode=wangpan");
                break;
        }
        offNodes.push(offNode);
        parentDiv.prepend(offNode);
    }
    $("body").append(parentDiv);
    parentDiv.mouseleave(function(e){
        parentDiv.css("display","none");
        for(var node of offNodes){
            node.css("margin-top","0px");
        }
    });

    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];
                let clone=$(curNode).clone().addClass('whx-a').css("background-color","#e1e1e1").css("outline","none").css("padding","0px").css("height","25px").css("width","25px").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();
                clone.mouseover(function(e){
                    offUrl=clone.attr("href");
                    parentDiv.css("display","block");
                    var basePos=clone.offset();
                    parentDiv.offset({top:basePos.top,left:basePos.left});
                    for(var x=0;x<4;x++){
                        offNodes[x].css("margin-top",-x*25+"px");
                    }
                });
                $(curNode).after(clone);
            }
        }
    }
}

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=b65]').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);