Accelerider Jump Tool

将百度网盘分享链接跳转到坐骑以高速下载

目前為 2017-04-23 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Accelerider Jump Tool
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  将百度网盘分享链接跳转到坐骑以高速下载
// @author       Mrs4s
// @match        *://pan.baidu.com/s/*
// @match        *://yun.baidu.com/s/*
// @match        *://pan.baidu.com/share/link*
// @match        *://yun.baidu.com/share/link*
// @require      https://code.jquery.com/jquery-latest.js
// @grant        unsafeWindow
// ==/UserScript==

(function () {
    'use strict';
    var yunData = unsafeWindow.yunData;
    console.log("ShareId: "+yunData.SHARE_ID+" ShareUk="+yunData.SHARE_UK+" PublicShare: "+isPublicShare());
    console.log(yunData);
    //自动跳转http,本地server不支持https
    if(location.protocol=="https:"){
        window.location.href="http://"+location.hostname+location.pathname;
        return;
    }
    addButton();
    //判断是单个文件分享还是文件夹或者多文件分享
    function isSingleShare() {
        return yunData.getContext === undefined ? true : false;
    }
    function isPublicShare(){
        return yunData.SHARE_PUBLIC==1;
    }


    //source  https://greasyfork.org/zh-CN/scripts/23635-%E7%99%BE%E5%BA%A6%E7%BD%91%E7%9B%98%E7%9B%B4%E6%8E%A5%E4%B8%8B%E8%BD%BD%E5%8A%A9%E6%89%8B
    function addButton() {
        if (isSingleShare()) {
            $('div.slide-show-right').css('width', '500px');
            $('div.frame-main').css('width', '96%');
            $('div.share-file-viewer').css('width', '740px').css('margin-left', 'auto').css('margin-right', 'auto');
        }
        else
            $('div.slide-show-right').css('width', '500px');
        var $dropdownbutton = $('<span class="g-dropdown-button"></span>');
        var $dropdownbutton_a = $('<a class="g-button" data-button-id="b200" data-button-index="200" href="javascript:void(0);"></a>');
        var $dropdownbutton_a_span = $('<span class="g-button-right"><em class="icon icon-download" title="发送到坐骑下载"></em><span class="text" style="width: auto;">发送到坐骑下载</span></span>');
        var $dropdownbutton_span = $('<span class="menu" style="width:auto;z-index:31"></span>');
        var $downloadButton = $('<a data-menu-id="b-menu207" class="g-button-menu" href="javascript:void(0);">点我发送</a>');
        //$dropdownbutton_span.append($downloadButton);
        $dropdownbutton_a.append($dropdownbutton_a_span);
        $dropdownbutton.append($dropdownbutton_a).append($dropdownbutton_span);

        $dropdownbutton.hover(function () {
            $dropdownbutton.toggleClass('button-open');
        });
        $dropdownbutton_a_span.click(downloadButtonClick);
        $downloadButton.click(downloadButtonClick);
        $('div.module-share-top-bar div.bar div.button-box').append($dropdownbutton);
    }
    function downloadButtonClick(){
        $.ajax({
            url:"http://localhost:9384/?shareid="+yunData.SHARE_ID+"&shareuk="+yunData.SHARE_UK+"&public="+yunData.SHARE_PUBLIC,
            method:"GET",
            async:false,
            dataType:"json",
            success:function(response){
                console.log("success");
            },
            error:function(response){
                console.log("fail");
                alert("发送失败,请确认你已经打开了坐骑?");
            }
        });
    }
})();