开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 1432|回复: 5
收起左侧

[完成] 求百度云解析方法【限速也没事,要直链就行】

 关闭 [复制链接]
结帖率:100% (11/11)
发表于 2020-4-6 12:19:11 | 显示全部楼层 |阅读模式   浙江省温州市
5精币
如题:我想写一个百度云直链解析,限速也没事!


求大佬给一个解析直链的源码


最佳答案

查看完整内容

这样这是一个JS代码看看:
结帖率:89% (72/81)
发表于 2020-4-6 12:19:12 | 显示全部楼层   四川省德阳市
这样这是一个JS代码看看:

  1. (function () {
  2.     'use strict';

  3.     var $ = $ || window.$;
  4.     var log_count = 1;
  5.     var wordMapHttp = {
  6.         'list-grid-switch': 'auiaQNyn',
  7.         'list-switched-on': 'ksbXZm',
  8.         'grid-switched-on': 'tch6W25',
  9.         'list-switch': 'lrbo9a',
  10.         'grid-switch': 'xh6poL',
  11.         'checkbox': 'EOGexf',  //ok
  12.         'chekbox-grid': 'cEefyz',
  13.         'col-item': 'Qxyfvg',
  14.         'check': 'fydGNC',
  15.         'checked': 'EzubGg',
  16.         'list-view': 'vdAfKMb',
  17.         'item-active': 'xrmQgr8',
  18.         'grid-view': 'JKvHJMb',
  19.         'bar-search': 'OFaPaO',
  20.         //'default-dom':'etr9DPv',
  21.         //'bar':'ccjr9DVe',
  22.         'list-tools': 'QDDOQB'
  23.     };
  24.     $(function () {
  25.         wordMapHttp['default-dom'] = ($('.icon-upload').parent().parent().parent().parent().parent().attr('class'));
  26.         wordMapHttp['bar'] = ($('.icon-upload').parent().parent().parent().parent().attr('class'));
  27.     });
  28.     var wordMapHttps = {
  29.         'list-grid-switch': 'auiaQNyn',
  30.         'list-switched-on': 'ewXm1e',
  31.         'grid-switched-on': 'kxhkX2Em',
  32.         'list-switch': 'rvpXm63',
  33.         'grid-switch': 'mxgdJgwv',
  34.         'checkbox': 'EOGexf',
  35.         'col-item': 'Qxyfvg',
  36.         'check': 'fydGNC',
  37.         'checked': 'EzubGg',
  38.         'chekbox-grid': 'cEefyz',
  39.         'list-view': 'vdAfKMb',
  40.         'item-active': 'xrmQgr8',
  41.         'grid-view': 'JKvHJMb',
  42.         'bar-search': 'OFaPaO',
  43.         //'default-dom':'qkk3LED',
  44.         //'bar':'cfj3L8W',
  45.         'list-tools': 'QDDOQB'
  46.     };
  47.     var wordMap = location.protocol == 'http:' ? wordMapHttp : wordMapHttps;

  48.     //console.log(wordMap);

  49.     //替换网址为高级下载链接 默认不替换 http不用传
  50.     function replaceDownloadLink(link, http) {
  51.         var http = http || false;
  52.         //是否强制将https替换为http
  53.         if (http) {
  54.             return link.replace('https://d.pcs.baidu.com', 'http://yqall02.baidupcs.com');
  55.         } else {
  56.             return link.replace('d.pcs.baidu.com', 'yqall02.baidupcs.com');
  57.         }
  58.     }

  59.     function slog(c1, c2, c3) {
  60.         c1 = c1 ? c1 : '';
  61.         c2 = c2 ? c2 : '';
  62.         c3 = c3 ? c3 : '';
  63.         console.log('#' + log_count++ + '-BaiDuNetdiskHelper-log:', c1, c2, c3);
  64.     }

  65.     $(function () {
  66.         switch (detectPage()) {
  67.             case 'disk':
  68.                 var panHelper = new PanHelper();
  69.                 panHelper.init();
  70.                 return;
  71.             case 'share':
  72.             case 's':
  73.                 var panShareHelper = new PanShareHelper();
  74.                 panShareHelper.init();
  75.                 return;
  76.             default:
  77.                 return;
  78.         }
  79.     });

  80.     //网盘页面的下载助手
  81.     function PanHelper() {
  82.         var yunData, sign, timestamp, bdstoken, logid, fid_list;
  83.         var fileList = [], selectFileList = [], batchLinkList = [], batchLinkListAll = [], linkList = [],
  84.             list_grid_status = 'list';
  85.         var observer, currentPage, currentPath, currentCategory, dialog, searchKey;
  86.         var panAPIUrl = location.protocol + "//" + location.host + "/api/";
  87.         var restAPIUrl = location.protocol + "//pcs.baidu.com/rest/2.0/pcs/";
  88.         var clientAPIUrl = location.protocol + "//d.pcs.baidu.com/rest/2.0/pcs/";

  89.         this.init = function () {
  90.             yunData = unsafeWindow.yunData;
  91.             slog('yunData:', yunData);
  92.             if (yunData === undefined) {
  93.                 slog('页面未正常加载,或者百度已经更新!');
  94.                 return;
  95.             }
  96.             initParams();
  97.             registerEventListener();
  98.             createObserver();
  99.             addButton();
  100.             createIframe();
  101.             dialog = new Dialog({addCopy: true});

  102.             slog('网盘直接下载助手加载成功!');
  103.         };

  104.         function initParams() {
  105.             sign = getSign();
  106.             timestamp = getTimestamp();
  107.             bdstoken = getBDStoken();
  108.             logid = getLogID();
  109.             currentPage = getCurrentPage();
  110.             slog('Current display mode:', currentPage);

  111.             if (currentPage == 'all')
  112.                 currentPath = getPath();

  113.             if (currentPage == 'category')
  114.                 currentCategory = getCategory();

  115.             if (currentPage == 'search')
  116.                 searchKey = getSearchKey();

  117.             refreshListGridStatus();
  118.             refreshFileList();
  119.             refreshSelectList();
  120.         }

  121.         function refreshFileList() {
  122.             if (currentPage == 'all') {
  123.                 fileList = getFileList();
  124.             } else if (currentPage == 'category') {
  125.                 fileList = getCategoryFileList();
  126.             } else if (currentPage == 'search') {
  127.                 fileList = getSearchFileList();
  128.             }
  129.         }

  130.         function refreshSelectList() {
  131.             selectFileList = [];
  132.         }

  133.         function refreshListGridStatus() {
  134.             list_grid_status = getListGridStatus();
  135.         }

  136.         //获取当前的视图模式
  137.         function getListGridStatus() {
  138.             if ($('.grid-switched-on').length > 0) {
  139.                 return 'grid'
  140.             } else {
  141.                 return 'list'
  142.             }
  143.         }

  144.         function registerEventListener() {
  145.             registerHashChange();
  146.             registerListGridStatus();
  147.             registerCheckbox();
  148.             registerAllCheckbox();
  149.             registerFileSelect();
  150.         }

  151.         //监视地址栏#标签的变化
  152.         function registerHashChange() {
  153.             window.addEventListener('hashchange', function (e) {
  154.                 refreshListGridStatus();

  155.                 if (getCurrentPage() == 'all') {
  156.                     if (currentPage == getCurrentPage()) {
  157.                         if (currentPath == getPath()) {
  158.                             return;
  159.                         } else {
  160.                             currentPath = getPath();
  161.                             refreshFileList();
  162.                             refreshSelectList();
  163.                         }
  164.                     } else {
  165.                         currentPage = getCurrentPage();
  166.                         currentPath = getPath();
  167.                         refreshFileList();
  168.                         refreshSelectList();
  169.                     }
  170.                 } else if (getCurrentPage() == 'category') {
  171.                     if (currentPage == getCurrentPage()) {
  172.                         if (currentCategory == getCategory()) {
  173.                             return;
  174.                         } else {
  175.                             currentPage = getCurrentPage();
  176.                             currentCategory = getCategory();
  177.                             refreshFileList();
  178.                             refreshSelectList();
  179.                         }
  180.                     } else {
  181.                         currentPage = getCurrentPage();
  182.                         currentCategory = getCategory();
  183.                         refreshFileList();
  184.                         refreshSelectList();
  185.                     }
  186.                 } else if (getCurrentPage() == 'search') {
  187.                     if (currentPage == getCurrentPage()) {
  188.                         if (searchKey == getSearchKey()) {
  189.                             return;
  190.                         } else {
  191.                             currentPage = getCurrentPage();
  192.                             searchKey = getSearchKey();
  193.                             refreshFileList();
  194.                             refreshSelectList();
  195.                         }
  196.                     } else {
  197.                         currentPage = getCurrentPage();
  198.                         searchKey = getSearchKey();
  199.                         refreshFileList();
  200.                         refreshSelectList();
  201.                     }
  202.                 }
  203.             });
  204.         }

  205.         //监视视图变化
  206.         function registerListGridStatus() {
  207.             var $a_list = $('a[data-type=list]');
  208.             $a_list.click(function () {
  209.                 list_grid_status = 'list';
  210.             });

  211.             var $a_grid = $('a[data-type=grid]');
  212.             $a_grid.click(function () {
  213.                 list_grid_status = 'grid';
  214.             });
  215.         }

  216.         //文件选择框
  217.         function registerCheckbox() {
  218.             var $checkbox = $('span.' + wordMap['checkbox']);
  219.             if (list_grid_status == 'grid') {
  220.                 $checkbox = $('.' + wordMap['chekbox-grid']);
  221.             }

  222.             //console.log($checkbox);
  223.             $checkbox.each(function (index, element) {
  224.                 $(element).bind('click', function (e) {
  225.                     var $parent = $(this).parent();
  226.                     var filename;

  227.                     if (list_grid_status == 'list') {
  228.                         filename = $('div.file-name div.text a', $parent).attr('title');
  229.                     } else if (list_grid_status == 'grid') {
  230.                         filename = $('div.file-name a', $parent).attr('title');
  231.                     }
  232.                     //if($parent.hasClass('item-active')){
  233.                     //if($parent.hasClass('prWzXA')){
  234.                     //console.log(fileList);
  235.                     if ($parent.hasClass(wordMap['item-active'])) {
  236.                         slog('取消选中文件:' + filename);
  237.                         for (var i = 0; i < selectFileList.length; i++) {
  238.                             if (selectFileList[i].filename == filename) {
  239.                                 selectFileList.splice(i, 1);
  240.                             }
  241.                         }
  242.                     } else {
  243.                         slog('选中文件:' + filename);
  244.                         //console.log(fileList);
  245.                         $.each(fileList, function (index, element) {
  246.                             if (element.server_filename == filename) {
  247.                                 var obj = {
  248.                                     filename: element.server_filename,
  249.                                     path: element.path,
  250.                                     fs_id: element.fs_id,
  251.                                     isdir: element.isdir
  252.                                 };
  253.                                 selectFileList.push(obj);
  254.                             }
  255.                         });
  256.                     }
  257.                 });
  258.             });
  259.         }

  260.         function unregisterCheckbox() {
  261.             //var $checkbox = $('span.checkbox');
  262.             //var $checkbox = $('span.EOGexf');
  263.             var $checkbox = $('span.' + wordMap['checkbox']);
  264.             $checkbox.each(function (index, element) {
  265.                 $(element).unbind('click');
  266.             });
  267.         }

  268.         //全选框
  269.         function registerAllCheckbox() {
  270.             //var $checkbox = $('div.col-item.check');
  271.             //var $checkbox = $('div.Qxyfvg.fydGNC');
  272.             var $checkbox = $('div.' + wordMap['col-item'] + '.' + wordMap['check']);
  273.             $checkbox.each(function (index, element) {
  274.                 $(element).bind('click', function (e) {
  275.                     var $parent = $(this).parent();
  276.                     //if($parent.hasClass('checked')){
  277.                     //if($parent.hasClass('EzubGg')){
  278.                     if ($parent.hasClass(wordMap['checked'])) {
  279.                         slog('取消全选');
  280.                         selectFileList = [];
  281.                     } else {
  282.                         slog('全部选中');
  283.                         selectFileList = [];
  284.                         $.each(fileList, function (index, element) {
  285.                             var obj = {
  286.                                 filename: element.server_filename,
  287.                                 path: element.path,
  288.                                 fs_id: element.fs_id,
  289.                                 isdir: element.isdir
  290.                             };
  291.                             selectFileList.push(obj);
  292.                         });
  293.                     }
  294.                 });
  295.             });
  296.         }

  297.         function unregisterAllCheckbox() {
  298.             //var $checkbox = $('div.col-item.check');
  299.             //var $checkbox = $('div.Qxyfvg.fydGNC');
  300.             var $checkbox = $('div.' + wordMap['col-item'] + '.' + wordMap['check']);
  301.             $checkbox.each(function (index, element) {
  302.                 $(element).unbind('click');
  303.             });
  304.         }

  305.         //单个文件选中,点击文件不是点击选中框,会只选中该文件
  306.         function registerFileSelect() {
  307.             //var $dd = $('div.list-view dd');
  308.             //var $dd = $('div.vdAfKMb dd');
  309.             var $dd = $('div.' + wordMap['list-view'] + ' dd');
  310.             $dd.each(function (index, element) {
  311.                 $(element).bind('click', function (e) {
  312.                     var nodeName = e.target.nodeName.toLowerCase();
  313.                     if (nodeName != 'span' && nodeName != 'a' && nodeName != 'em') {
  314.                         slog('shiftKey:' + e.shiftKey);
  315.                         if (!e.shiftKey) {
  316.                             selectFileList = [];
  317.                             var filename = $('div.file-name div.text a', $(this)).attr('title');
  318.                             slog('选中文件:' + filename);
  319.                             $.each(fileList, function (index, element) {
  320.                                 if (element.server_filename == filename) {
  321.                                     var obj = {
  322.                                         filename: element.server_filename,
  323.                                         path: element.path,
  324.                                         fs_id: element.fs_id,
  325.                                         isdir: element.isdir
  326.                                     };
  327.                                     selectFileList.push(obj);
  328.                                 }
  329.                             });
  330.                         } else {
  331.                             selectFileList = [];
  332.                             //var $dd_select = $('div.list-view dd.item-active');
  333.                             //var $dd_select = $('div.vdAfKMb dd.prWzXA');
  334.                             var $dd_select = $('div.' + wordMap['list-view'] + ' dd.' + wordMap['item-active']);
  335.                             $.each($dd_select, function (index, element) {
  336.                                 var filename = $('div.file-name div.text a', $(element)).attr('title');
  337.                                 slog('选中文件:' + filename);
  338.                                 $.each(fileList, function (index, element) {
  339.                                     if (element.server_filename == filename) {
  340.                                         var obj = {
  341.                                             filename: element.server_filename,
  342.                                             path: element.path,
  343.                                             fs_id: element.fs_id,
  344.                                             isdir: element.isdir
  345.                                         };
  346.                                         selectFileList.push(obj);
  347.                                     }
  348.                                 });
  349.                             });
  350.                         }
  351.                     }
  352.                 });
  353.             });
  354.         }

  355.         function unregisterFileSelect() {
  356.             //var $dd = $('div.list-view dd');
  357.             //var $dd = $('div.vdAfKMb dd');
  358.             var $dd = $('div.' + wordMap['list-view'] + ' dd');
  359.             $dd.each(function (index, element) {
  360.                 $(element).unbind('click');
  361.             });
  362.         }

  363.         //监视文件列表显示变化
  364.         function createObserver() {
  365.             var MutationObserver = window.MutationObserver;
  366.             var options = {
  367.                 'childList': true
  368.             };
  369.             observer = new MutationObserver(function (mutations) {
  370.                 unregisterCheckbox();
  371.                 unregisterAllCheckbox();
  372.                 unregisterFileSelect();
  373.                 registerCheckbox();
  374.                 registerAllCheckbox();
  375.                 registerFileSelect();
  376.             });

  377.             //var list_view = document.querySelector('.list-view');
  378.             //var grid_view = document.querySelector('.grid-view');

  379.             //var list_view = document.querySelector('.vdAfKMb');
  380.             //var grid_view = document.querySelector('.JKvHJMb');

  381.             var list_view = document.querySelector('.' + wordMap['list-view']);
  382.             var grid_view = document.querySelector('.' + wordMap['grid-view']);

  383.             //console.log(list_view);
  384.             observer.observe(list_view, options);
  385.             observer.observe(grid_view, options);
  386.         }

  387.         //添加助手按钮
  388.         function addButton() {
  389.             //$('div.bar-search').css('width','18%');//修改搜索框的宽度,避免遮挡
  390.             //$('div.OFaPaO').css('width','18%');
  391.             $('div.' + wordMap['bar-search']).css('width', '18%');
  392.             var $dropdownbutton = $('<span class="g-dropdown-button"></span>');
  393.             var $dropdownbutton_a = $('<a class="g-button" href="javascript:void(0);"><span class="g-button-right"><em class="icon icon-download" title="百度网盘下载助手"></em><span class="text" style="width: auto;">下载助手</span></span></a>');
  394.             var $dropdownbutton_span = $('<span class="menu" style="width:96px"></span>');

  395.             var $directbutton = $('<span class="g-button-menu" style="display:block"></span>');
  396.             var $directbutton_span = $('<span class="g-dropdown-button g-dropdown-button-second" menulevel="2"></span>');
  397.             var $directbutton_a = $('<a class="g-button" href="javascript:void(0);"><span class="g-button-right"><span class="text" style="width:auto">下载链接</span></span></a>');
  398.             var $directbutton_menu = $('<span class="menu" style="width:120px;left:79px"></span>');
  399.             var $directbutton_download_button = $('<a id="download-direct" class="g-button-menu" href="javascript:void(0);">点击直接下载</a>');
  400.             var $directbutton_link_button = $('<a id="link-direct" class="g-button-menu" href="javascript:void(0);">获取下载链接</a>');
  401.             var $directbutton_batchhttplink_button = $('<a id="batchhttplink-direct" class="g-button-menu" href="javascript:void(0);">批量获取(HTTP)</a>');
  402.             var $directbutton_batchhttpslink_button = $('<a id="batchhttpslink-direct" class="g-button-menu" href="javascript:void(0);">批量获取(HTTPS)</a>');
  403.             $directbutton_menu.append($directbutton_download_button).append($directbutton_link_button).append($directbutton_batchhttplink_button).append($directbutton_batchhttpslink_button);
  404.             $directbutton.append($directbutton_span.append($directbutton_a).append($directbutton_menu));
  405.             $directbutton.hover(function () {
  406.                 $directbutton_span.toggleClass('button-open');
  407.             });
  408.             $directbutton_download_button.click(downloadClick);
  409.             $directbutton_link_button.click(linkClick);
  410.             $directbutton_batchhttplink_button.click(batchClick);
  411.             $directbutton_batchhttpslink_button.click(batchClick);

  412.             var $apibutton = $('<span class="g-button-menu" style="display:block"></span>');
  413.             var $apibutton_span = $('<span class="g-dropdown-button g-dropdown-button-second" menulevel="2"></span>');
  414.             var $apibutton_a = $('<a class="g-button" href="javascript:void(0);"><span class="g-button-right"><span class="text" style="width:auto">压缩链接</span></span></a>');
  415.             var $apibutton_menu = $('<span class="menu" style="width:120px;left:77px"></span>');
  416.             var $apibutton_download_button = $('<a id="download-api" class="g-button-menu" href="javascript:void(0);">点击直接下载</a>');
  417.             var $apibutton_link_button = $('<a id="httplink-api" class="g-button-menu" href="javascript:void(0);">获取压缩链接</a>');
  418.             var $apibutton_batchhttplink_button = $('<a id="batchhttplink-api" class="g-button-menu" href="javascript:void(0);">批量获取(HTTP)</a>');
  419.             var $apibutton_batchhttpslink_button = $('<a id="batchhttpslink-api" class="g-button-menu" href="javascript:void(0);">批量获取(HTTPS)</a>');
  420.             $apibutton_menu.append($apibutton_download_button).append($apibutton_link_button).append($apibutton_batchhttplink_button).append($apibutton_batchhttpslink_button);
  421.             $apibutton.append($apibutton_span.append($apibutton_a).append($apibutton_menu));
  422.             $apibutton.hover(function () {
  423.                 $apibutton_span.toggleClass('button-open');
  424.             });
  425.             $apibutton_download_button.click(downloadClick);
  426.             $apibutton_link_button.click(linkClick);
  427.             $apibutton_batchhttplink_button.click(batchClick);
  428.             $apibutton_batchhttpslink_button.click(batchClick);

  429.             var $outerlinkbutton = $('<span class="g-button-menu" style="display:none"></span>');  //改为block显示外链下载
  430.             var $outerlinkbutton_span = $('<span class="g-dropdown-button g-dropdown-button-second" menulevel="2"></span>');
  431.             var $outerlinkbutton_a = $('<a class="g-button" href="javascript:void(0);"><span class="g-button-right"><span class="text" style="width:auto">外链下载</span></span></a>');
  432.             var $outerlinkbutton_menu = $('<span class="menu" style="width:120px;left:79px"></span>');
  433.             var $outerlinkbutton_download_button = $('<a id="download-outerlink" class="g-button-menu" href="javascript:void(0);">下载</a>');
  434.             var $outerlinkbutton_link_button = $('<a id="link-outerlink" class="g-button-menu" href="javascript:void(0);">显示链接</a>');
  435.             var $outerlinkbutton_batchlink_button = $('<a id="batchlink-outerlink" class="g-button-menu" href="javascript:void(0);">批量链接</a>');
  436.             $outerlinkbutton_menu.append($outerlinkbutton_download_button).append($outerlinkbutton_link_button).append($outerlinkbutton_batchlink_button);
  437.             $outerlinkbutton.append($outerlinkbutton_span.append($outerlinkbutton_a).append($outerlinkbutton_menu));
  438.             $outerlinkbutton.hover(function () {
  439.                 $outerlinkbutton_span.toggleClass('button-open');
  440.             });
  441.             $outerlinkbutton_download_button.click(downloadClick);
  442.             $outerlinkbutton_link_button.click(linkClick);
  443.             $outerlinkbutton_batchlink_button.click(batchClick);

  444.             $dropdownbutton_span.append($directbutton).append($apibutton).append($outerlinkbutton);
  445.             $dropdownbutton.append($dropdownbutton_a).append($dropdownbutton_span);

  446.             $dropdownbutton.hover(function () {
  447.                 $dropdownbutton.toggleClass('button-open');
  448.             });

  449.             $('div.' + wordMap['default-dom'] + ' div.' + wordMap['bar'] + ' div.' + wordMap['list-tools']).prepend($dropdownbutton);
  450.             $('div.' + wordMap['list-tools']).prepend($dropdownbutton)
  451.         }

  452.         // 我的网盘选择文件下载下载
  453.         function downloadClick(event) {
  454.             //console.log('downloadClick');
  455.             slog('选中文件列表:', selectFileList);
  456.             var id = event.target.id;
  457.             var downloadLink;

  458.             if (id == 'download-direct') {
  459.                 var downloadType;
  460.                 if (selectFileList.length === 0) {
  461.                     alert("获取选中文件失败,请刷新重试!");
  462.                     return;
  463.                 } else if (selectFileList.length == 1) {
  464.                     if (selectFileList[0].isdir === 1)
  465.                         downloadType = 'batch';
  466.                     else if (selectFileList[0].isdir === 0)
  467.                         downloadType = 'dlink';
  468.                     //downloadType = selectFileList[0].isdir==1?'batch':(selectFileList[0].isdir===0?'dlink':'batch');
  469.                 } else if (selectFileList.length > 1) {
  470.                     downloadType = 'batch';
  471.                 }

  472.                 fid_list = getFidList(selectFileList);
  473.                 var result = getDownloadLinkWithPanAPI(downloadType);
  474.                 if (result.errno === 0) {
  475.                     if (downloadType == 'dlink')
  476.                         downloadLink = result.dlink[0].dlink;
  477.                     else if (downloadType == 'batch') {
  478.                         downloadLink = result.dlink;
  479.                         if (selectFileList.length === 1)
  480.                             downloadLink = downloadLink + '&zipname=' + encodeURIComponent(selectFileList[0].filename) + '.zip';
  481.                     }
  482.                     else {
  483.                         alert("发生错误!");
  484.                         return;
  485.                     }
  486.                 } else if (result.errno == -1) {
  487.                     alert('文件不存在或已被百度和谐,无法下载!');
  488.                     return;
  489.                 } else if (result.errno == 112) {
  490.                     alert("页面过期,请刷新重试!");
  491.                     return;
  492.                 } else {
  493.                     alert("发生错误!");
  494.                     return;
  495.                 }
  496.             } else {
  497.                 if (selectFileList.length === 0) {
  498.                     alert("获取选中文件失败,请刷新重试!");
  499.                     return;
  500.                 } else if (selectFileList.length > 1) {
  501.                     alert("该方法不支持获取多文件下载链接!");
  502.                     return;
  503.                 } else {
  504.                     if (selectFileList[0].isdir == 1) {
  505.                         alert("该方法不支持获取文件夹下载链接!");
  506.                         return;
  507.                     }
  508.                 }
  509.                 if (id == 'download-api') {
  510.                     downloadLink = getDownloadLinkWithRESTAPIBaidu(selectFileList[0].path);
  511.                 } else if (id == 'download-outerlink') {
  512.                     var result = getDownloadLinkWithClientAPI(selectFileList[0].path);
  513.                     if (result.errno == 0) {
  514.                         downloadLink = result.urls[0].url;
  515.                     } else if (result.errno == 1) {
  516.                         alert('文件不存在!');
  517.                         return;
  518.                     } else if (result.errno == 2) {
  519.                         alert('文件不存在或者已被百度和谐,无法下载!');
  520.                         return;
  521.                     } else {
  522.                         alert('发生错误!');
  523.                         return;
  524.                     }
  525.                 }
  526.             }
  527.             execDownload(downloadLink);
  528.         }

  529.         //我的网盘 - 获取下载链接
  530.         function linkClick(event) {
  531.             //console.log('linkClick');
  532.             slog('选中文件列表:', selectFileList);
  533.             var id = event.target.id;
  534.             var linkList, tip;

  535.             if (id.indexOf('direct') != -1) {
  536.                 var downloadType;
  537.                 var downloadLink;
  538.                 if (selectFileList.length === 0) {
  539.                     alert("获取选中文件失败,请刷新重试!");
  540.                     return;
  541.                 } else if (selectFileList.length == 1) {
  542.                     if (selectFileList[0].isdir === 1)
  543.                         downloadType = 'batch';
  544.                     else if (selectFileList[0].isdir === 0)
  545.                         downloadType = 'dlink';
  546.                 } else if (selectFileList.length > 1) {
  547.                     downloadType = 'batch';
  548.                 }
  549.                 fid_list = getFidList(selectFileList);
  550.                 var result = getDownloadLinkWithPanAPI(downloadType);
  551.                 if (result.errno === 0) {
  552.                     if (downloadType == 'dlink')
  553.                         downloadLink = result.dlink[0].dlink;
  554.                     else if (downloadType == 'batch') {
  555.                         slog(selectFileList);
  556.                         downloadLink = result.dlink;
  557.                         if (selectFileList.length === 1)
  558.                             downloadLink = downloadLink + '&zipname=' + encodeURIComponent(selectFileList[0].filename) + '.zip';
  559.                     }
  560.                     else {
  561.                         alert("发生错误!");
  562.                         return;
  563.                     }
  564.                 } else if (result.errno == -1) {
  565.                     alert('文件不存在或已被百度和谐,无法下载!');
  566.                     return;
  567.                 } else if (result.errno == 112) {
  568.                     alert("页面过期,请刷新重试!");
  569.                     return;
  570.                 } else {
  571.                     alert("发生错误!");
  572.                     return;
  573.                 }
  574.                 var httplink = downloadLink.replace(/^([A-Za-z]+):/, 'http:');
  575.                 //httplink = replaceDownloadLink(httplink);
  576.                 var httpslink = downloadLink.replace(/^([A-Za-z]+):/, 'https:');
  577.                 //httpslink = replaceDownloadLink(httpslink);
  578.                 var filename = '';
  579.                 $.each(selectFileList, function (index, element) {
  580.                     if (selectFileList.length == 1)
  581.                         filename = element.filename;
  582.                     else {
  583.                         if (index == 0)
  584.                             filename = element.filename;
  585.                         else
  586.                             filename = filename + ',' + element.filename;
  587.                     }
  588.                 });
  589.                 linkList = {
  590.                     filename: filename,
  591.                     urls: [
  592.                         {url: httplink, rank: 1},
  593.                         {url: httpslink, rank: 2}
  594.                     ]
  595.                 };
  596.                 tip = '提示:单文件获取的是没有压缩的下载直链,多文件和文件夹获取的是打包压缩的下载直链。//压缩的下载直链可用下载工具下载超级加速!';
  597.                 dialog.open({title: '下载链接', type: 'link', list: linkList, tip: tip});
  598.             } else {
  599.                 if (selectFileList.length === 0) {
  600.                     alert("获取选中文件失败,请刷新重试!");
  601.                     return;
  602.                 } else if (selectFileList.length > 1) {
  603.                     alert("该方法不支持多文件下载!");
  604.                     return;
  605.                 } else {
  606.                     if (selectFileList[0].isdir == 1) {
  607.                         alert("该方法不支持目录下载!");
  608.                         return;
  609.                     }
  610.                 }
  611.                 if (id.indexOf('api') != -1) {
  612.                     var downloadLink = getDownloadLinkWithRESTAPIBaidu(selectFileList[0].path);
  613.                     var httplink = downloadLink.replace(/^([A-Za-z]+):/, 'http:');
  614.                     var httpslink = downloadLink.replace(/^([A-Za-z]+):/, 'https:');
  615.                     linkList = {
  616.                         filename: selectFileList[0].filename,
  617.                         urls: [
  618.                             {url: httplink, rank: 1},
  619.                             {url: httpslink, rank: 2}
  620.                         ]
  621.                     };
  622.                     httplink = httplink.replace('250528', '266719');
  623.                     httpslink = httpslink.replace('250528', '266719');
  624.                     linkList.urls.push({url: httplink, rank: 3});
  625.                     linkList.urls.push({url: httpslink, rank: 4});
  626.                     tip = '注意:不支持多文件/文件夹获取打包压缩链接!压缩直链可以用下载工具超级加速,复制到下载工具需传递Cookie。';
  627.                     dialog.open({title: '压缩下载链接', type: 'link', list: linkList, tip: tip});
  628.                 } else if (id.indexOf('outerlink') != -1) {
  629.                     var result = getDownloadLinkWithClientAPI(selectFileList[0].path);
  630.                     if (result.errno == 0) {
  631.                         linkList = {
  632.                             filename: selectFileList[0].filename,
  633.                             urls: result.urls
  634.                         };
  635.                     } else if (result.errno == 1) {
  636.                         alert('文件不存在!');
  637.                         return;
  638.                     } else if (result.errno == 2) {
  639.                         alert('文件不存在或者已被百度和谐,无法下载!');
  640.                         return;
  641.                     } else {
  642.                         alert('发生错误!');
  643.                         return;
  644.                     }
  645.                     tip = '提示:获取打包压缩链接不支持多文件及文件夹!压缩下载链接可以用下载工具超级加速,不需要传递Cookie。';
  646.                     dialog.open({
  647.                         title: '下载链接',
  648.                         type: 'link',
  649.                         list: linkList,
  650.                         tip: tip,
  651.                         showcopy: true,
  652.                         showedit: true
  653.                     });
  654.                 }
  655.             }
  656.             //dialog.open({title:'下载链接',type:'link',list:linkList,tip:tip});
  657.         }

  658.         // 我的网盘 - 批量下载
  659.         function batchClick(event) {
  660.             //console.log('batchClick');
  661.             slog('选中文件列表:', selectFileList);
  662.             if (selectFileList.length === 0) {
  663.                 alert('获取选中文件失败,请刷新重试!');
  664.                 return;
  665.             }
  666.             var id = event.target.id;
  667.             var linkType, tip;
  668.             linkType = id.indexOf('https') == -1 ? (id.indexOf('http') == -1 ? location.protocol + ':' : 'http:') : 'https:';
  669.             batchLinkList = [];
  670.             batchLinkListAll = [];
  671.             if (id.indexOf('direct') != -1) {
  672.                 batchLinkList = getDirectBatchLink(linkType);
  673.                 tip = '提示:这里是批量获取的所有选中文件的直接下载链接,多文件/文件夹是打包压缩的下载直链。';
  674.                 if (batchLinkList.length === 0) {
  675.                     alert('没有链接可以显示,API链接不要全部选中文件夹!');
  676.                     return;
  677.                 }
  678.                 dialog.open({title:'批量获取链接',type:'batch',list:batchLinkList,tip:tip,showcopy:true});
  679.             } else if (id.indexOf('api') != -1) {
  680.                 batchLinkList = getAPIBatchLink(linkType);
  681.                 tip = '提示:这里不支持获取多文件/文件夹的打包压缩下载链接,仅显示所有选中单文件的压缩下载直链';
  682.                 if (batchLinkList.length === 0) {
  683.                     alert('没有链接可以显示,API链接不要全部选中文件夹!');
  684.                     return;
  685.                 }
  686.                 dialog.open({title: '批量获取链接', type: 'batch', list: batchLinkList, tip: tip, showcopy: true});
  687.             } else if (id.indexOf('outerlink') != -1) {
  688.                 batchLinkListAll = getOuterlinkBatchLinkAll();
  689.                 batchLinkList = getOuterlinkBatchLinkFirst(batchLinkListAll);
  690.                 tip = '显示所有选中文件的外部下载链接,不显示文件夹';
  691.                 if (batchLinkList.length === 0) {
  692.                     alert('没有链接可以显示,API链接不要全部选中文件夹!');
  693.                     return;
  694.                 }

  695.                 dialog.open({
  696.                     title: '获取链接',
  697.                     type: 'batch',
  698.                     list: batchLinkList,
  699.                     tip: tip,
  700.                     showcopy: true,
  701.                     alllist: batchLinkListAll,
  702.                     showall: true
  703.                 });
  704.             }

  705.             //dialog.open({title:'批量获取链接',type:'batch',list:batchLinkList,tip:tip,showcopy:true});
  706.         }

  707.         function getDirectBatchLink(linkType) {
  708.             var list = [];
  709.             $.each(selectFileList, function (index, element) {
  710.                 var downloadType, downloadLink, result;
  711.                 if (element.isdir == 0)
  712.                     downloadType = 'dlink';
  713.                 else
  714.                     downloadType = 'batch';
  715.                 fid_list = getFidList([element]);
  716.                 result = getDownloadLinkWithPanAPI(downloadType);
  717.                 if (result.errno == 0) {
  718.                     if (downloadType == 'dlink')
  719.                         downloadLink = result.dlink[0].dlink;
  720.                     else if (downloadType == 'batch')
  721.                         downloadLink = result.dlink;
  722.                     downloadLink = downloadLink.replace(/^([A-Za-z]+):/, linkType);
  723.                     //downloadLink = replaceDownloadLink(downloadLink);
  724.                 } else {
  725.                     downloadLink = 'error';
  726.                 }
  727.                 list.push({filename: element.filename, downloadlink: downloadLink});
  728.             });
  729.             return list;
  730.         }

  731.         function getAPIBatchLink(linkType) {
  732.             var list = [];
  733.             $.each(selectFileList, function (index, element) {
  734.                 if (element.isdir == 1)
  735.                     return;
  736.                 var downloadLink;
  737.                 downloadLink = getDownloadLinkWithRESTAPIBaidu(element.path);
  738.                 downloadLink = downloadLink.replace(/^([A-Za-z]+):/, linkType);
  739.                 list.push({filename: element.filename, downloadlink: downloadLink});
  740.             });
  741.             return list;
  742.         }

  743.         function getOuterlinkBatchLinkAll() {
  744.             var list = [];
  745.             $.each(selectFileList, function (index, element) {
  746.                 var result;
  747.                 if (element.isdir == 1)
  748.                     return;
  749.                 result = getDownloadLinkWithClientAPI(element.path);
  750.                 if (result.errno == 0) {
  751.                     list.push({filename: element.filename, links: result.urls});
  752.                 } else {
  753.                     list.push({filename: element.filename, links: [{rank: 1, url: 'error'}]});
  754.                 }
  755.             });
  756.             return list;
  757.         }

  758.         function getOuterlinkBatchLinkFirst(list) {
  759.             var result = [];
  760.             $.each(list, function (index, element) {
  761.                 result.push({filename: element.filename, downloadlink: element.links[0].url});
  762.             });
  763.             return result;
  764.         }

  765.         function getSign() {
  766.             var signFnc;
  767.             try {
  768.                 signFnc = new Function("return " + yunData.sign2)();
  769.             } catch (e) {
  770.                 throw new Error(e.message);
  771.             }
  772.             return base64Encode(signFnc(yunData.sign5, yunData.sign1));
  773.         }

  774.         //获取当前目录
  775.         function getPath() {
  776.             var hash = location.hash;
  777.             var regx = new RegExp("path=([^&]*)(&|$)", 'i');
  778.             var result = hash.match(regx);
  779.             //console.log(result);
  780.             return decodeURIComponent(result[1]);
  781.         }

  782.         //获取分类显示的类别,即地址栏中的type
  783.         function getCategory() {
  784.             var hash = location.hash;
  785.             var regx = new RegExp("path=([^&]*)(&|$)", 'i');
  786.             var result = hash.match(regx);
  787.             return decodeURIComponent(result[1]);
  788.         }

  789.         function getSearchKey() {
  790.             var hash = location.hash;
  791.             var regx = new RegExp("key=([^&]*)(&|$)", 'i');
  792.             var result = hash.match(regx);
  793.             return decodeURIComponent(result[1]);
  794.         }

  795.         //获取当前页面(all或者category或search)
  796.         function getCurrentPage() {
  797.             var hash = location.hash;
  798.             //console.log(hash.substring(hash.indexOf('#') + 2, hash.indexOf('?')));
  799.             return hash.substring(hash.indexOf('#') + 2, hash.indexOf('?'));
  800.         }

  801.         //获取文件列表
  802.         function getFileList() {
  803.             var filelist = [];
  804.             var listUrl = panAPIUrl + "list";
  805.             var path = getPath();
  806.             logid = getLogID();
  807.             var params = {
  808.                 dir: path,
  809.                 bdstoken: bdstoken,
  810.                 logid: logid,
  811.                 order: 'size',
  812.                 desc: 0,
  813.                 clienttype: 0,
  814.                 showempty: 0,
  815.                 web: 1,
  816.                 channel: 'chunlei',
  817.                 appid: 250528
  818.             };

  819.             $.ajax({
  820.                 url: listUrl,
  821.                 async: false,
  822.                 method: 'GET',
  823.                 data: params,
  824.                 success: function (response) {
  825.                     filelist = 0 === response.errno ? response.list : [];
  826.                 }
  827.             });
  828.             return filelist;
  829.         }

  830.         //获取分类页面下的文件列表
  831.         function getCategoryFileList() {
  832.             var filelist = [];
  833.             var listUrl = panAPIUrl + "categorylist";
  834.             var category = getCategory();
  835.             logid = getLogID();
  836.             var params = {
  837.                 category: category,
  838.                 bdstoken: bdstoken,
  839.                 logid: logid,
  840.                 order: 'size',
  841.                 desc: 0,
  842.                 clienttype: 0,
  843.                 showempty: 0,
  844.                 web: 1,
  845.                 channel: 'chunlei',
  846.                 appid: 250528
  847.             };
  848.             $.ajax({
  849.                 url: listUrl,
  850.                 async: false,
  851.                 method: 'GET',
  852.                 data: params,
  853.                 success: function (response) {
  854.                     filelist = 0 === response.errno ? response.info : [];
  855.                 }
  856.             });
  857.             return filelist;
  858.         }

  859.         function getSearchFileList() {
  860.             var filelist = [];
  861.             var listUrl = panAPIUrl + 'search';
  862.             logid = getLogID();
  863.             searchKey = getSearchKey();
  864.             var params = {
  865.                 recursion: 1,
  866.                 order: 'time',
  867.                 desc: 1,
  868.                 showempty: 0,
  869.                 web: 1,
  870.                 page: 1,
  871.                 num: 100,
  872.                 key: searchKey,
  873.                 channel: 'chunlei',
  874.                 app_id: 250528,
  875.                 bdstoken: bdstoken,
  876.                 logid: logid,
  877.                 clienttype: 0
  878.             };
  879.             $.ajax({
  880.                 url: listUrl,
  881.                 async: false,
  882.                 method: 'GET',
  883.                 data: params,
  884.                 success: function (response) {
  885.                     filelist = 0 === response.errno ? response.list : [];
  886.                 }
  887.             });
  888.             return filelist;
  889.         }

  890.         //生成下载时的fid_list参数
  891.         function getFidList(list) {
  892.             var fidlist = null;
  893.             if (list.length === 0)
  894.                 return null;
  895.             var fileidlist = [];
  896.             $.each(list, function (index, element) {
  897.                 fileidlist.push(element.fs_id);
  898.             });
  899.             fidlist = '[' + fileidlist + ']';
  900.             return fidlist;
  901.         }

  902.         function getTimestamp() {
  903.             return yunData.timestamp;
  904.         }

  905.         function getBDStoken() {
  906.             return yunData.MYBDSTOKEN;
  907.         }

  908.         //获取直接下载地址
  909.         //这个地址不是直接下载地址,访问这个地址会返回302,response header中的location才是真实下载地址
  910.         //暂时没有找到提取方法
  911.         function getDownloadLinkWithPanAPI(type) {
  912.             var downloadUrl = panAPIUrl + "download";
  913.             var result;
  914.             logid = getLogID();
  915.             var params = {
  916.                 sign: sign,
  917.                 timestamp: timestamp,
  918.                 fidlist: fid_list,
  919.                 type: type,
  920.                 channel: 'chunlei',
  921.                 web: 1,
  922.                 app_id: 250528,
  923.                 bdstoken: bdstoken,
  924.                 logid: logid,
  925.                 clienttype: 0
  926.             };
  927.             $.ajax({
  928.                 url: downloadUrl,
  929.                 async: false,
  930.                 method: 'GET',
  931.                 data: params,
  932.                 success: function (response) {
  933.                     result = response;
  934.                 }
  935.             });
  936.             return result;
  937.         }

  938.         function getDownloadLinkWithRESTAPIBaidu(path) {
  939.             var link = restAPIUrl + 'file?method=download&app_id=250528&path=' + encodeURIComponent(path);
  940.             return link;
  941.         }

  942.         function getDownloadLinkWithRESTAPIES(path) {
  943.             var link = restAPIUrl + 'file?method=download&app_id=266719&path=' + encodeURIComponent(path);
  944.             return link;
  945.         }

  946.         function getDownloadLinkWithClientAPI(path) {
  947.             var result;
  948.             var url = clientAPIUrl + 'file?method=locatedownload&app_id=250528&ver=4.0&path=' + encodeURIComponent(path);
  949.             $.ajax({
  950.                 url: url,
  951.                 method: 'POST',
  952.                 xhrFields: {
  953.                     withCredentials: true
  954.                 },
  955.                 async: false,
  956.                 success: function (response) {
  957.                     result = JSON.parse(response);
  958.                 },
  959.                 statusCode: {
  960.                     404: function (response) {
  961.                         result = response;
  962.                     }
  963.                 }
  964.             });
  965.             if (result) {
  966.                 if (result.error_code == undefined) {
  967.                     if (result.urls == undefined) {
  968.                         result.errno = 2;
  969.                     } else {
  970.                         $.each(result.urls, function (index, element) {
  971.                             result.urls[index].url = element.url.replace('\\', '');
  972.                         });
  973.                         result.errno = 0;
  974.                     }
  975.                 } else if (result.error_code == 31066) {
  976.                     result.errno = 1;
  977.                 } else {
  978.                     result.errno = -1;
  979.                 }
  980.             } else {
  981.                 result = {};
  982.                 result.errno = -1;
  983.             }
  984.             return result;
  985.         }

  986.         function execDownload(link) {
  987.             slog("下载链接:" + link);
  988.             $('#helperdownloadiframe').attr('src', link);
  989.         }

  990.         function createIframe() {
  991.             var $div = $('<div class="helper-hide" style="padding:0;margin:0;display:block"></div>');
  992.             var $iframe = $('<iframe src="javascript:void(0)" id="helperdownloadiframe" style="display:none"></iframe>');
  993.             $div.append($iframe);
  994.             $('body').append($div);

  995.         }
  996.     }

  997.     //分享页面的下载助手
  998.     function PanShareHelper() {
  999.         var yunData, sign, timestamp, bdstoken, channel, clienttype, web, app_id, logid, encrypt, product, uk,
  1000.             primaryid, fid_list, extra, shareid;
  1001.         var vcode;
  1002.         var shareType, buttonTarget, currentPath, list_grid_status, observer, dialog, vcodeDialog;
  1003.         var fileList = [], selectFileList = [];
  1004.         var panAPIUrl = location.protocol + "//" + location.host + "/api/";
  1005.         var shareListUrl = location.protocol + "//" + location.host + "/share/list";

  1006.         this.init = function () {
  1007.             yunData = unsafeWindow.yunData;
  1008.             slog('yunData:', yunData);
  1009.             if (yunData === undefined || yunData.FILEINFO == null) {
  1010.                 slog('页面未正常加载,或者百度已经更新!');
  1011.                 return;
  1012.             }
  1013.             initParams();
  1014.             addButton();
  1015.             dialog = new Dialog({addCopy: false});
  1016.             vcodeDialog = new VCodeDialog(refreshVCode, confirmClick);
  1017.             createIframe();

  1018.             if (!isSingleShare()) {
  1019.                 registerEventListener();
  1020.                 createObserver();
  1021.             }

  1022.             slog('分享直接下载加载成功!');
  1023.         };

  1024.         function initParams() {
  1025.             shareType = getShareType();
  1026.             sign = yunData.SIGN;
  1027.             timestamp = yunData.TIMESTAMP;
  1028.             bdstoken = yunData.MYBDSTOKEN;
  1029.             channel = 'chunlei';
  1030.             clienttype = 0;
  1031.             web = 1;
  1032.             app_id = 250528;
  1033.             logid = getLogID();
  1034.             encrypt = 0;
  1035.             product = 'share';
  1036.             primaryid = yunData.SHARE_ID;
  1037.             uk = yunData.SHARE_UK;

  1038.             if (shareType == 'secret') {
  1039.                 extra = getExtra();
  1040.             }
  1041.             if (isSingleShare()) {
  1042.                 var obj = {};
  1043.                 if (yunData.CATEGORY == 2) {
  1044.                     obj.filename = yunData.FILENAME;
  1045.                     obj.path = yunData.PATH;
  1046.                     obj.fs_id = yunData.FS_ID;
  1047.                     obj.isdir = 0;
  1048.                 } else {
  1049.                     obj.filename = yunData.FILEINFO[0].server_filename,
  1050.                         obj.path = yunData.FILEINFO[0].path,
  1051.                         obj.fs_id = yunData.FILEINFO[0].fs_id,
  1052.                         obj.isdir = yunData.FILEINFO[0].isdir
  1053.                 }
  1054.                 selectFileList.push(obj);
  1055.             } else {
  1056.                 shareid = yunData.SHARE_ID;
  1057.                 currentPath = getPath();
  1058.                 list_grid_status = getListGridStatus();
  1059.                 fileList = getFileList();
  1060.             }
  1061.         }

  1062.         //判断分享类型(public或者secret)
  1063.         function getShareType() {
  1064.             return yunData.SHARE_PUBLIC === 1 ? 'public' : 'secret';
  1065.         }

  1066.         //判断是单个文件分享还是文件夹或者多文件分享
  1067.         function isSingleShare() {
  1068.             return yunData.getContext === undefined ? true : false;
  1069.         }

  1070.         //判断是否为自己的分享链接
  1071.         function isSelfShare() {
  1072.             return yunData.MYSELF == 1 ? true : false;
  1073.         }

  1074.         function getExtra() {
  1075.             var seKey = decodeURIComponent(getCookie('BDCLND'));
  1076.             return '{' + '"sekey":"' + seKey + '"' + "}";
  1077.         }

  1078.         //获取当前目录
  1079.         function getPath() {
  1080.             var hash = location.hash;
  1081.             var regx = new RegExp("path=([^&]*)(&|$)", 'i');
  1082.             var result = hash.match(regx);
  1083.             return decodeURIComponent(result[1]);
  1084.         }

  1085.         //获取当前的视图模式
  1086.         function getListGridStatus() {
  1087.             var status = 'list';
  1088.             if ($('.list-switched-on').length > 0) {
  1089.                 status = 'list';
  1090.             } else if ($('.grid-switched-on').length > 0) {
  1091.                 status = 'grid';
  1092.             }
  1093.             return status;
  1094.         }

  1095.         //添加下载助手按钮
  1096.         function addButton() {
  1097.             if (isSingleShare()) {
  1098.                 $('div.slide-show-right').css('width', '500px');
  1099.                 $('div.frame-main').css('width', '96%');
  1100.                 $('div.share-file-viewer').css('width', '740px').css('margin-left', 'auto').css('margin-right', 'auto');
  1101.             }
  1102.             else
  1103.                 $('div.slide-show-right').css('width', '500px');
  1104.             var $dropdownbutton = $('<span class="g-dropdown-button"></span>');
  1105.             var $dropdownbutton_a = $('<a class="g-button" data-button-id="b200" data-button-index="200" href="javascript:void(0);"></a>');
  1106.             var $dropdownbutton_a_span = $('<span class="g-button-right"><em class="icon icon-download" title="百度网盘下载助手"></em><span class="text" style="width: auto;">下载助手</span></span>');
  1107.             var $dropdownbutton_span = $('<span class="menu" style="width:auto;z-index:41"></span>');

  1108.             var $downloadButton = $('<a data-menu-id="b-menu207" class="g-button-menu" href="javascript:void(0);">点击直接下载</a>');
  1109.             var $linkButton = $('<a data-menu-id="b-menu208" class="g-button-menu" href="javascript:void(0);">获取下载链接</a>');

  1110.             $dropdownbutton_span.append($downloadButton).append($linkButton);
  1111.             $dropdownbutton_a.append($dropdownbutton_a_span);
  1112.             $dropdownbutton.append($dropdownbutton_a).append($dropdownbutton_span);

  1113.             $dropdownbutton.hover(function () {
  1114.                 $dropdownbutton.toggleClass('button-open');
  1115.             });

  1116.             $downloadButton.click(downloadButtonClick);
  1117.             $linkButton.click(linkButtonClick);

  1118.             $('div.module-share-top-bar div.bar div.x-button-box').append($dropdownbutton);
  1119.         }

  1120.         function createIframe() {
  1121.             var $div = $('<div class="helper-hide" style="padding:0;margin:0;display:block"></div>');
  1122.             var $iframe = $('<iframe src="javascript:void(0)" id="helperdownloadiframe" style="display:none"></iframe>');
  1123.             $div.append($iframe);
  1124.             $('body').append($div);
  1125.         }

  1126.         function registerEventListener() {
  1127.             registerHashChange();
  1128.             registerListGridStatus();
  1129.             registerCheckbox();
  1130.             registerAllCheckbox();
  1131.             registerFileSelect();
  1132.         }

  1133.         //监视地址栏#标签变化
  1134.         function registerHashChange() {
  1135.             window.addEventListener('hashchange', function (e) {
  1136.                 list_grid_status = getListGridStatus();
  1137.                 if (currentPath == getPath()) {
  1138.                     return;
  1139.                 } else {
  1140.                     currentPath = getPath();
  1141.                     refreshFileList();
  1142.                     refreshSelectFileList();
  1143.                 }
  1144.             });
  1145.         }

  1146.         function refreshFileList() {
  1147.             fileList = getFileList();
  1148.         }

  1149.         function refreshSelectFileList() {
  1150.             selectFileList = [];
  1151.         }

  1152.         //监视视图变化
  1153.         function registerListGridStatus() {
  1154.             var $a_list = $('a[data-type=list]');
  1155.             $a_list.click(function () {
  1156.                 list_grid_status = 'list';
  1157.             });

  1158.             var $a_grid = $('a[data-type=grid]');
  1159.             $a_grid.click(function () {
  1160.                 list_grid_status = 'grid';
  1161.             });
  1162.         }

  1163.         //监视文件选择框
  1164.         function registerCheckbox() {
  1165.             //var $checkbox = $('span.checkbox');
  1166.             var $checkbox = $('span.' + wordMap['checkbox']);
  1167.             $checkbox.each(function (index, element) {
  1168.                 $(element).bind('click', function (e) {
  1169.                     var $parent = $(this).parent();
  1170.                     var filename;
  1171.                     if (list_grid_status == 'list') {
  1172.                         filename = $('div.file-name div.text a', $parent).attr('title');
  1173.                     } else if (list_grid_status == 'grid') {
  1174.                         filename = $('div.file-name a', $parent).attr('title');
  1175.                     }
  1176.                     if ($parent.hasClass('item-active')) {
  1177.                         slog('取消选中文件:' + filename);
  1178.                         for (var i = 0; i < selectFileList.length; i++) {
  1179.                             if (selectFileList[i].filename == filename) {
  1180.                                 selectFileList.splice(i, 1);
  1181.                             }
  1182.                         }
  1183.                     } else {
  1184.                         slog('选中文件:' + filename);
  1185.                         $.each(fileList, function (index, element) {
  1186.                             if (element.server_filename == filename) {
  1187.                                 var obj = {
  1188.                                     filename: element.server_filename,
  1189.                                     path: element.path,
  1190.                                     fs_id: element.fs_id,
  1191.                                     isdir: element.isdir
  1192.                                 };
  1193.                                 selectFileList.push(obj);
  1194.                             }
  1195.                         });
  1196.                     }
  1197.                 });
  1198.             });
  1199.         }

  1200.         function unregisterCheckbox() {
  1201.             //var $checkbox = $('span.checkbox');
  1202.             var $checkbox = $('span.' + wordMap['checkbox']);
  1203.             $checkbox.each(function (index, element) {
  1204.                 $(element).unbind('click');
  1205.             });
  1206.         }

  1207.         //监视全选框
  1208.         function registerAllCheckbox() {
  1209.             //var $checkbox = $('div.col-item.check');
  1210.             var $checkbox = $('div.' + wordMap['col-item'] + '.' + wordMap['check']);
  1211.             $checkbox.each(function (index, element) {
  1212.                 $(element).bind('click', function (e) {
  1213.                     var $parent = $(this).parent();
  1214.                     //if($parent.hasClass('checked')){
  1215.                     if ($parent.hasClass(wordMap['checked'])) {
  1216.                         slog('取消全选');
  1217.                         selectFileList = [];
  1218.                     } else {
  1219.                         slog('全部选中');
  1220.                         selectFileList = [];
  1221.                         $.each(fileList, function (index, element) {
  1222.                             var obj = {
  1223.                                 filename: element.server_filename,
  1224.                                 path: element.path,
  1225.                                 fs_id: element.fs_id,
  1226.                                 isdir: element.isdir
  1227.                             };
  1228.                             selectFileList.push(obj);
  1229.                         });
  1230.                     }
  1231.                 });
  1232.             });
  1233.         }

  1234.         function unregisterAllCheckbox() {
  1235.             //var $checkbox = $('div.col-item.check');
  1236.             var $checkbox = $('div.' + wordMap['col-item'] + '.' + wordMap['check']);
  1237.             $checkbox.each(function (index, element) {
  1238.                 $(element).unbind('click');
  1239.             });
  1240.         }

  1241.         //监视单个文件选中
  1242.         function registerFileSelect() {
  1243.             console.log('registerFileSelect');
  1244.             //var $dd = $('div.list-view dd');
  1245.             var $dd = $('div.' + wordMap['list-view'] + ' dd');
  1246.             $dd.each(function (index, element) {
  1247.                 $(element).bind('click', function (e) {
  1248.                     var nodeName = e.target.nodeName.toLowerCase();
  1249.                     if (nodeName != 'span' && nodeName != 'a' && nodeName != 'em') {
  1250.                         selectFileList = [];
  1251.                         var filename = $('div.file-name div.text a', $(this)).attr('title');
  1252.                         slog('选中文件:' + filename);
  1253.                         $.each(fileList, function (index, element) {
  1254.                             if (element.server_filename == filename) {
  1255.                                 var obj = {
  1256.                                     filename: element.server_filename,
  1257.                                     path: element.path,
  1258.                                     fs_id: element.fs_id,
  1259.                                     isdir: element.isdir
  1260.                                 };
  1261.                                 selectFileList.push(obj);
  1262.                             }
  1263.                         });
  1264.                     }
  1265.                 });
  1266.             });
  1267.         }

  1268.         function unregisterFileSelect() {
  1269.             //var $dd = $('div.list-view dd');
  1270.             var $dd = $('div.' + wordMap['list-view'] + ' dd');
  1271.             $dd.each(function (index, element) {
  1272.                 $(element).unbind('click');
  1273.             });
  1274.         }

  1275.         //监视文件列表显示变化
  1276.         function createObserver() {
  1277.             var MutationObserver = window.MutationObserver;
  1278.             var options = {
  1279.                 'childList': true
  1280.             };
  1281.             observer = new MutationObserver(function (mutations) {
  1282.                 unregisterCheckbox();
  1283.                 unregisterAllCheckbox();
  1284.                 unregisterFileSelect();
  1285.                 registerCheckbox();
  1286.                 registerAllCheckbox();
  1287.                 registerFileSelect();
  1288.             });
  1289.             //var list_view = document.querySelector('.list-view');
  1290.             //var grid_view = document.querySelector('.grid-view');

  1291.             var list_view = document.querySelector('.' + wordMap['list-view']);
  1292.             var grid_view = document.querySelector('.' + wordMap['grid-view']);

  1293.             observer.observe(list_view, options);
  1294.             observer.observe(grid_view, options);
  1295.         }

  1296.         //获取文件信息列表
  1297.         function getFileList() {
  1298.             var result = [];
  1299.             if (getPath() == '/') {
  1300.                 result = yunData.FILEINFO;
  1301.             } else {
  1302.                 logid = getLogID();
  1303.                 var params = {
  1304.                     uk: uk,
  1305.                     shareid: shareid,
  1306.                     order: 'other',
  1307.                     desc: 1,
  1308.                     showempty: 0,
  1309.                     web: web,
  1310.                     dir: getPath(),
  1311.                     t: Math.random(),
  1312.                     bdstoken: bdstoken,
  1313.                     channel: channel,
  1314.                     clienttype: clienttype,
  1315.                     app_id: app_id,
  1316.                     logid: logid
  1317.                 };
  1318.                 $.ajax({
  1319.                     url: shareListUrl,
  1320.                     method: 'GET',
  1321.                     async: false,
  1322.                     data: params,
  1323.                     success: function (response) {
  1324.                         if (response.errno === 0) {
  1325.                             result = response.list;
  1326.                         }
  1327.                     }
  1328.                 });
  1329.             }
  1330.             return result;
  1331.         }

  1332.         function downloadButtonClick() {
  1333.             //console.log('点击直接下载按钮');
  1334.             slog('选中文件列表:', selectFileList);
  1335.             if (selectFileList.length === 0) {
  1336.                 alert('获取文件ID失败,请重试');
  1337.                 return;
  1338.             }
  1339.             buttonTarget = 'download';
  1340.             var downloadLink = getDownloadLink();

  1341.             if (downloadLink.errno == -20) {
  1342.                 vcode = getVCode();
  1343.                 if (vcode.errno !== 0) {
  1344.                     alert('获取验证码失败!');
  1345.                     return;
  1346.                 }
  1347.                 vcodeDialog.open(vcode);
  1348.             } else if (downloadLink.errno == 112) {
  1349.                 alert('页面过期,请刷新重试');
  1350.                 return;
  1351.             } else if (downloadLink.errno === 0) {
  1352.                 var link;
  1353.                 if (selectFileList.length == 1 && selectFileList[0].isdir === 0)
  1354.                     link = downloadLink.list[0].dlink;
  1355.                 else
  1356.                     link = downloadLink.dlink;
  1357.                 //link = link.replace("https://d.pcs.baidu.com","http://yqall02.baidupcs.com");
  1358.                 execDownload(link);
  1359.             } else {
  1360.                 alert('获取下载链接失败!');
  1361.                 return;
  1362.             }
  1363.         }

  1364.         //获取验证码
  1365.         function getVCode() {
  1366.             var url = panAPIUrl + 'getvcode';
  1367.             var result;
  1368.             logid = getLogID();
  1369.             var params = {
  1370.                 prod: 'pan',
  1371.                 t: Math.random(),
  1372.                 bdstoken: bdstoken,
  1373.                 channel: channel,
  1374.                 clienttype: clienttype,
  1375.                 web: web,
  1376.                 app_id: app_id,
  1377.                 logid: logid
  1378.             };
  1379.             $.ajax({
  1380.                 url: url,
  1381.                 method: 'GET',
  1382.                 async: false,
  1383.                 data: params,
  1384.                 success: function (response) {
  1385.                     result = response;
  1386.                 }
  1387.             });
  1388.             return result;
  1389.         }

  1390.         //刷新验证码
  1391.         function refreshVCode() {
  1392.             vcode = getVCode();
  1393.             $('#dialog-img').attr('src', vcode.img);
  1394.         }

  1395.         //验证码确认提交
  1396.         function confirmClick() {
  1397.             var val = $('#dialog-input').val();
  1398.             if (val.length === 0) {
  1399.                 $('#dialog-err').text('请输入验证码');
  1400.                 return;
  1401.             } else if (val.length < 4) {
  1402.                 $('#dialog-err').text('验证码输入错误,请重新输入');
  1403.                 return;
  1404.             }
  1405.             var result = getDownloadLinkWithVCode(val);
  1406.             if (result.errno == -20) {
  1407.                 vcodeDialog.close();
  1408.                 $('#dialog-err').text('验证码输入错误,请重新输入');
  1409.                 refreshVCode();
  1410.                 if (!vcode || vcode.errno !== 0) {
  1411.                     alert('获取验证码失败!');
  1412.                     return;
  1413.                 }
  1414.                 vcodeDialog.open();
  1415.             } else if (result.errno === 0) {
  1416.                 vcodeDialog.close();
  1417.                 var link;
  1418.                 if (selectFileList.length == 1 && selectFileList[0].isdir === 0)
  1419.                     link = result.list[0].dlink;
  1420.                 else
  1421.                     link = result.dlink;
  1422.                 if (buttonTarget == 'download') {
  1423.                     execDownload(link);
  1424.                 } else if (buttonTarget == 'link') {
  1425.                     var filename = '';
  1426.                     $.each(selectFileList, function (index, element) {
  1427.                         if (selectFileList.length == 1)
  1428.                             filename = element.filename;
  1429.                         else {
  1430.                             if (index == 0)
  1431.                                 filename = element.filename;
  1432.                             else
  1433.                                 filename = filename + ',' + element.filename;
  1434.                         }
  1435.                     });
  1436.                     //link = replaceDownloadLink(link, true);
  1437.                     var linkList = {
  1438.                         filename: filename,
  1439.                         urls: [
  1440.                             {url: link, rank: 1}
  1441.                         ]
  1442.                     };
  1443.                     var tip = "提示:单文件获取的是直接下载链接,多文件和文件夹获取的是打包压缩下载直链!(压缩链接可以使用下载工具超级加速)";
  1444.                     dialog.open({title:'直接下载地址',type:'link',list:linkList,tip:tip});
  1445.                 }
  1446.             } else {
  1447.                 alert('发生错误!');
  1448.                 return;
  1449.             }
  1450.         }

  1451.         //生成下载用的fid_list参数
  1452.         function getFidList() {
  1453.             var fidlist = [];
  1454.             $.each(selectFileList, function (index, element) {
  1455.                 fidlist.push(element.fs_id);
  1456.             });
  1457.             return '[' + fidlist + ']';
  1458.         }

  1459.         function linkButtonClick() {
  1460.             slog('选中文件列表:', selectFileList);
  1461.             if (selectFileList.length === 0) {
  1462.                 alert('没有选中文件,请重试');
  1463.                 return;
  1464.             }
  1465.             buttonTarget = 'link';
  1466.             var downloadLink = getDownloadLink();

  1467.             if (downloadLink.errno == -20) {
  1468.                 vcode = getVCode();
  1469.                 if (!vcode || vcode.errno !== 0) {
  1470.                     alert('获取验证码失败!');
  1471.                     return;
  1472.                 }
  1473.                 vcodeDialog.open(vcode);
  1474.             } else if (downloadLink.errno == 112) {
  1475.                 alert('页面过期,请刷新重试');
  1476.                 return;
  1477.             } else if (downloadLink.errno === 0) {
  1478.                 var link;
  1479.                 if (selectFileList.length == 1 && selectFileList[0].isdir === 0)
  1480.                     link = downloadLink.list[0].dlink;
  1481.                 else
  1482.                     link = downloadLink.dlink;
  1483.                 if (selectFileList.length == 1)
  1484.                     $('#dialog-downloadlink').attr('href', link).text(link);
  1485.                 else
  1486.                     $('#dialog-downloadlink').attr('href', link).text(link);
  1487.                 var filename = '';
  1488.                 $.each(selectFileList, function (index, element) {
  1489.                     if (selectFileList.length == 1)
  1490.                         filename = element.filename;
  1491.                     else {
  1492.                         if (index == 0)
  1493.                             filename = element.filename;
  1494.                         else
  1495.                             filename = filename + ',' + element.filename;
  1496.                     }
  1497.                 });
  1498.                 //link = replaceDownloadLink(link, true);
  1499.                 var linkList = {
  1500.                     filename: filename,
  1501.                     urls: [
  1502.                         {url: link, rank: 1}
  1503.                     ]
  1504.                 };
  1505.                 var tip = "提示:单文件获取的是直接下载链接,多文件和文件夹获取的是打包压缩下载直链!(压缩链接可以使用下载工具超级加速)'";
  1506.                 dialog.open({title:'直接下载地址',type:'link',list:linkList,tip:tip});
  1507.             } else {
  1508.                 alert('获取下载链接失败!');
  1509.                 return;
  1510.             }
  1511.         }

  1512.         //获取下载链接
  1513.         function getDownloadLink() {
  1514.             var result;
  1515.             if (isSingleShare) {
  1516.                 fid_list = getFidList();
  1517.                 logid = getLogID();
  1518.                 var url = panAPIUrl + 'sharedownload?sign=' + sign + '×tamp=' + timestamp + '&bdstoken=' + bdstoken + '&channel=' + channel + '&clienttype=' + clienttype + '&web=' + web + '&app_id=' + app_id + '&logid=' + logid;
  1519.                 var params = {
  1520.                     encrypt: encrypt,
  1521.                     product: product,
  1522.                     uk: uk,
  1523.                     primaryid: primaryid,
  1524.                     fid_list: fid_list
  1525.                 };
  1526.                 if (shareType == 'secret') {
  1527.                     params.extra = extra;
  1528.                 }
  1529.                 if (selectFileList[0].isdir == 1 || selectFileList.length > 1) {
  1530.                     params.type = 'batch';
  1531.                 }
  1532.                 $.ajax({
  1533.                     url: url,
  1534.                     method: 'POST',
  1535.                     async: false,
  1536.                     data: params,
  1537.                     success: function (response) {
  1538.                         result = response;
  1539.                     }
  1540.                 });
  1541.             }
  1542.             return result;
  1543.         }

  1544.         //有验证码输入时获取下载链接
  1545.         function getDownloadLinkWithVCode(vcodeInput) {
  1546.             var result;
  1547.             if (isSingleShare) {
  1548.                 fid_list = getFidList();
  1549.                 var url = panAPIUrl + 'sharedownload?sign=' + sign + '×tamp=' + timestamp + '&bdstoken=' + bdstoken + '&channel=' + channel + '&clienttype=' + clienttype + '&web=' + web + '&app_id=' + app_id + '&logid=' + logid;
  1550.                 var params = {
  1551.                     encrypt: encrypt,
  1552.                     product: product,
  1553.                     vcode_input: vcodeInput,
  1554.                     vcode_str: vcode.vcode,
  1555.                     uk: uk,
  1556.                     primaryid: primaryid,
  1557.                     fid_list: fid_list
  1558.                 };
  1559.                 if (shareType == 'secret') {
  1560.                     params.extra = extra;
  1561.                 }
  1562.                 if (selectFileList[0].isdir == 1 || selectFileList.length > 1) {
  1563.                     params.type = 'batch';
  1564.                 }
  1565.                 $.ajax({
  1566.                     url: url,
  1567.                     method: 'POST',
  1568.                     async: false,
  1569.                     data: params,
  1570.                     success: function (response) {
  1571.                         result = response;
  1572.                     }
  1573.                 });
  1574.             }
  1575.             return result;
  1576.         }

  1577.         function execDownload(link) {
  1578.             slog('下载链接:' + link);
  1579.             $('#helperdownloadiframe').attr('src', link);
  1580.         }
  1581.     }

  1582.     function base64Encode(t) {
  1583.         var a, r, e, n, i, s, o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  1584.         for (e = t.length, r = 0, a = ""; e > r;) {
  1585.             if (n = 255 & t.charCodeAt(r++), r == e) {
  1586.                 a += o.charAt(n >> 2);
  1587.                 a += o.charAt((3 & n) << 4);
  1588.                 a += "==";
  1589.                 break;
  1590.             }
  1591.             if (i = t.charCodeAt(r++), r == e) {
  1592.                 a += o.charAt(n >> 2);
  1593.                 a += o.charAt((3 & n) << 4 | (240 & i) >> 4);
  1594.                 a += o.charAt((15 & i) << 2);
  1595.                 a += "=";
  1596.                 break;
  1597.             }
  1598.             s = t.charCodeAt(r++);
  1599.             a += o.charAt(n >> 2);
  1600.             a += o.charAt((3 & n) << 4 | (240 & i) >> 4);
  1601.             a += o.charAt((15 & i) << 2 | (192 & s) >> 6);
  1602.             a += o.charAt(63 & s);
  1603.         }
  1604.         return a;
  1605.     }

  1606.     function detectPage() {
  1607.         var regx = /[\/].+[\/]/g;
  1608.         var page = location.pathname.match(regx);
  1609.         return page[0].replace(/\//g, '');
  1610.     }

  1611.     function getCookie(e) {
  1612.         var o, t;
  1613.         var n = document, c = decodeURI;
  1614.         return n.cookie.length > 0 && (o = n.cookie.indexOf(e + "="), -1 != o) ? (o = o + e.length + 1, t = n.cookie.indexOf(";", o), -1 == t && (t = n.cookie.length), c(n.cookie.substring(o, t))) : "";
  1615.     }

  1616.     function getLogID() {
  1617.         var name = "BAIDUID";
  1618.         var u = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/~!@#¥%……&";
  1619.         var d = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
  1620.         var f = String.fromCharCode;

  1621.         function l(e) {
  1622.             if (e.length < 2) {
  1623.                 var n = e.charCodeAt(0);
  1624.                 return 128 > n ? e : 2048 > n ? f(192 | n >>> 6) + f(128 | 63 & n) : f(224 | n >>> 12 & 15) + f(128 | n >>> 6 & 63) + f(128 | 63 & n);
  1625.             }
  1626.             var n = 65536 + 1024 * (e.charCodeAt(0) - 55296) + (e.charCodeAt(1) - 56320);
  1627.             return f(240 | n >>> 18 & 7) + f(128 | n >>> 12 & 63) + f(128 | n >>> 6 & 63) + f(128 | 63 & n);
  1628.         }

  1629.         function g(e) {
  1630.             return (e + "" + Math.random()).replace(d, l);
  1631.         }

  1632.         function m(e) {
  1633.             var n = [0, 2, 1][e.length % 3];
  1634.             var t = e.charCodeAt(0) << 16 | (e.length > 1 ? e.charCodeAt(1) : 0) << 8 | (e.length > 2 ? e.charCodeAt(2) : 0);
  1635.             var o = [u.charAt(t >>> 18), u.charAt(t >>> 12 & 63), n >= 2 ? "=" : u.charAt(t >>> 6 & 63), n >= 1 ? "=" : u.charAt(63 & t)];
  1636.             return o.join("");
  1637.         }

  1638.         function h(e) {
  1639.             return e.replace(/[\s\S]{1,3}/g, m);
  1640.         }

  1641.         function p() {
  1642.             return h(g((new Date()).getTime()));
  1643.         }

  1644.         function w(e, n) {
  1645.             return n ? p(String(e)).replace(/[+\/]/g, function (e) {
  1646.                 return "+" == e ? "-" : "_";
  1647.             }).replace(/=/g, "") : p(String(e));
  1648.         }

  1649.         return w(getCookie(name));
  1650.     }

  1651.     function Dialog() {
  1652.         var linkList = [];
  1653.         var showParams;
  1654.         var dialog, shadow;

  1655.         function createDialog() {
  1656.             var screenWidth = document.body.clientWidth;
  1657.             var dialogLeft = screenWidth > 800 ? (screenWidth - 800) / 2 : 0;
  1658.             var $dialog_div = $('<div class="dialog" style="width: 800px; top: 0px; bottom: auto; left: ' + dialogLeft + 'px; right: auto; display: hidden; visibility: visible; z-index: 52;"></div>');
  1659.             var $dialog_header = $('<div class="dialog-header"><h3><span class="dialog-title" style="display:inline-block;width:740px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis"></span></h3></div>');
  1660.             var $dialog_control = $('<div class="dialog-control"><span class="dialog-icon dialog-close">×</span></div>');
  1661.             var $dialog_body = $('<div class="dialog-body" style="max-height:450px;overflow-y:auto;padding:0 20px;"></div>');
  1662.             var $dialog_tip = $('<div class="dialog-tip" style="padding-left:20px;background-color:#faf2d3;border-top: 1px solid #c4dbfe;"><p></p></div>');

  1663.             $dialog_div.append($dialog_header.append($dialog_control)).append($dialog_body);

  1664.             //var $dialog_textarea = $('<textarea class="dialog-textarea" style="display:none;width"></textarea>');
  1665.             var $dialog_radio_div = $('<div class="dialog-radio" style="display:none;width:760px;padding-left:20px;padding-right:20px"></div>');
  1666.             var $dialog_radio_multi = $('<input type="radio" name="showmode" checked="checked" value="multi"><span>多行</span>');
  1667.             var $dialog_radio_single = $('<input type="radio" name="showmode" value="single"><span>单行</span>');
  1668.             $dialog_radio_div.append($dialog_radio_multi).append($dialog_radio_single);
  1669.             $dialog_div.append($dialog_radio_div);
  1670.             $('input[type=radio][name=showmode]', $dialog_radio_div).change(function () {
  1671.                 var value = this.value;
  1672.                 var $textarea = $('div.dialog-body textarea[name=dialog-textarea]', dialog);
  1673.                 var content = $textarea.val();
  1674.                 if (value == 'multi') {
  1675.                     content = content.replace(/\s+/g, '\n');
  1676.                     $textarea.css('height', '300px');
  1677.                 } else if (value == 'single') {
  1678.                     content = content.replace(/\n+/g, ' ');
  1679.                     $textarea.css('height', '');
  1680.                 }
  1681.                 $textarea.val(content);
  1682.             });

  1683.             var $dialog_button = $('<div class="dialog-button" style="display:none"></div>');
  1684.             var $dialog_button_div = $('<div style="display:table;margin:auto"></div>')
  1685.             var $dialog_copy_button = $('<button id="dialog-copy-button" style="display:none">复制</button>');
  1686.             var $dialog_edit_button = $('<button id="dialog-edit-button" style="display:none">编辑</button>');
  1687.             var $dialog_exit_button = $('<button id="dialog-exit-button" style="display:none">退出</button>');

  1688.             $dialog_button_div.append($dialog_copy_button).append($dialog_edit_button).append($dialog_exit_button);
  1689.             $dialog_button.append($dialog_button_div);
  1690.             $dialog_div.append($dialog_button);

  1691.             $dialog_copy_button.click(function () {
  1692.                 var content = '';
  1693.                 if (showParams.type == 'batch') {
  1694.                     $.each(linkList, function (index, element) {
  1695.                         if (element.downloadlink == 'error')
  1696.                             return;
  1697.                         if (index == linkList.length - 1)
  1698.                             content = content + element.downloadlink;
  1699.                         else
  1700.                             content = content + element.downloadlink + '\n';
  1701.                     });
  1702.                 } else if (showParams.type == 'link') {
  1703.                     $.each(linkList, function (index, element) {
  1704.                         if (element.url == 'error')
  1705.                             return;
  1706.                         if (index == linkList.length - 1)
  1707.                             content = content + element.url;
  1708.                         else
  1709.                             content = content + element.url + '\n';
  1710.                     });
  1711.                 }
  1712.                 GM_setClipboard(content, 'text');
  1713.                 alert('已将链接复制到剪贴板!');
  1714.             });

  1715.             $dialog_edit_button.click(function () {
  1716.                 var $dialog_textarea = $('div.dialog-body textarea[name=dialog-textarea]', dialog);
  1717.                 var $dialog_item = $('div.dialog-body div', dialog);
  1718.                 $dialog_item.hide();
  1719.                 $dialog_copy_button.hide();
  1720.                 $dialog_edit_button.hide();
  1721.                 $dialog_textarea.show();
  1722.                 $dialog_radio_div.show();
  1723.                 $dialog_exit_button.show();
  1724.             });

  1725.             $dialog_exit_button.click(function () {
  1726.                 var $dialog_textarea = $('div.dialog-body textarea[name=dialog-textarea]', dialog);
  1727.                 var $dialog_item = $('div.dialog-body div', dialog);
  1728.                 $dialog_textarea.hide();
  1729.                 $dialog_radio_div.hide();
  1730.                 $dialog_item.show();
  1731.                 $dialog_exit_button.hide();
  1732.                 $dialog_copy_button.show();
  1733.                 $dialog_edit_button.show();
  1734.             });

  1735.             $dialog_div.append($dialog_tip);
  1736.             $('body').append($dialog_div);
  1737.             $dialog_div.dialogDrag();
  1738.             $dialog_control.click(dialogControl);
  1739.             return $dialog_div;
  1740.         }

  1741.         function createShadow() {
  1742.             var $shadow = $('<div class="dialog-shadow" style="position: fixed; left: 0px; top: 0px; z-index: 50; background: rgb(0, 0, 0) none repeat scroll 0% 0%; opacity: 0.5; width: 100%; height: 100%; display: none;"></div>');
  1743.             $('body').append($shadow);
  1744.             return $shadow;
  1745.         }

  1746.         this.open = function (params) {
  1747.             showParams = params;
  1748.             linkList = [];
  1749.             if (params.type == 'link') {
  1750.                 linkList = params.list.urls;
  1751.                 $('div.dialog-header h3 span.dialog-title', dialog).text(params.title + ":" + params.list.filename);
  1752.                 $.each(params.list.urls, function (index, element) {
  1753.                     var $div = $('<div><div style="width:30px;float:left">' + element.rank + ':</div><div style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis"><a href="' + element.url + '">' + element.url + '</a></div></div>');
  1754.                     $('div.dialog-body', dialog).append($div);
  1755.                 });
  1756.             } else if (params.type == 'batch') {
  1757.                 linkList = params.list;
  1758.                 $('div.dialog-header h3 span.dialog-title', dialog).text(params.title);
  1759.                 if (params.showall) {
  1760.                     $.each(params.list, function (index, element) {
  1761.                         var $item_div = $('<div class="item-container" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap"></div>');
  1762.                         var $item_name = $('<div style="width:100px;float:left;overflow:hidden;text-overflow:ellipsis" title="' + element.filename + '">' + element.filename + '</div>');
  1763.                         var $item_sep = $('<div style="width:12px;float:left"><span>:</span></div>');
  1764.                         var $item_link_div = $('<div class="item-link" style="float:left;width:618px;"></div>');
  1765.                         var $item_first = $('<div class="item-first" style="overflow:hidden;text-overflow:ellipsis"><a href="' + element.downloadlink + '">' + element.downloadlink + '</a></div>');
  1766.                         $item_link_div.append($item_first);
  1767.                         $.each(params.alllist[index].links, function (n, item) {
  1768.                             if (element.downloadlink == item.url)
  1769.                                 return;
  1770.                             var $item = $('<div class="item-ex" style="display:none;overflow:hidden;text-overflow:ellipsis"><a href="' + item.url + '">' + item.url + '</a></div>');
  1771.                             $item_link_div.append($item);
  1772.                         });
  1773.                         var $item_ex = $('<div style="width:15px;float:left;cursor:pointer;text-align:center;font-size:16px"><span>+</span></div>');
  1774.                         $item_div.append($item_name).append($item_sep).append($item_link_div).append($item_ex);
  1775.                         $item_ex.click(function () {
  1776.                             var $parent = $(this).parent();
  1777.                             $parent.toggleClass('showall');
  1778.                             if ($parent.hasClass('showall')) {
  1779.                                 $(this).text('-');
  1780.                                 $('div.item-link div.item-ex', $parent).show();
  1781.                             } else {
  1782.                                 $(this).text('+');
  1783.                                 $('div.item-link div.item-ex', $parent).hide();
  1784.                             }
  1785.                         });
  1786.                         $('div.dialog-body', dialog).append($item_div);
  1787.                     });
  1788.                 } else {
  1789.                     $.each(params.list, function (index, element) {
  1790.                         var $div = $('<div style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap"><div style="width:100px;float:left;overflow:hidden;text-overflow:ellipsis" title="' + element.filename + '">' + element.filename + '</div><span>:</span><a href="' + element.downloadlink + '">' + element.downloadlink + '</a></div>');
  1791.                         $('div.dialog-body', dialog).append($div);
  1792.                     });
  1793.                 }
  1794.             }

  1795.             if (params.tip) {
  1796.                 $('div.dialog-tip p', dialog).text(params.tip);
  1797.             }

  1798.             if (params.showcopy) {
  1799.                 $('div.dialog-button', dialog).show();
  1800.                 $('div.dialog-button button#dialog-copy-button', dialog).show();
  1801.             }
  1802.             if (params.showedit) {
  1803.                 $('div.dialog-button', dialog).show();
  1804.                 $('div.dialog-button button#dialog-edit-button', dialog).show();
  1805.                 var $dialog_textarea = $('<textarea name="dialog-textarea" style="display:none;resize:none;width:758px;height:300px;white-space:pre;word-wrap:normal;overflow-x:scroll"></textarea>');
  1806.                 var content = '';
  1807.                 if (showParams.type == 'batch') {
  1808.                     $.each(linkList, function (index, element) {
  1809.                         if (element.downloadlink == 'error')
  1810.                             return;
  1811.                         if (index == linkList.length - 1)
  1812.                             content = content + element.downloadlink;
  1813.                         else
  1814.                             content = content + element.downloadlink + '\n';
  1815.                     });
  1816.                 } else if (showParams.type == 'link') {
  1817.                     $.each(linkList, function (index, element) {
  1818.                         if (element.url == 'error')
  1819.                             return;
  1820.                         if (index == linkList.length - 1)
  1821.                             content = content + element.url;
  1822.                         else
  1823.                             content = content + element.url + '\n';
  1824.                     });
  1825.                 }
  1826.                 $dialog_textarea.val(content);
  1827.                 $('div.dialog-body', dialog).append($dialog_textarea);
  1828.             }

  1829.             shadow.show();
  1830.             dialog.show();
  1831.         }

  1832.         this.close = function () {
  1833.             dialogControl();
  1834.         }

  1835.         function dialogControl() {
  1836.             $('div.dialog-body', dialog).children().remove();
  1837.             $('div.dialog-header h3 span.dialog-title', dialog).text('');
  1838.             $('div.dialog-tip p', dialog).text('');
  1839.             $('div.dialog-button', dialog).hide();
  1840.             $('div.dialog-radio input[type=radio][name=showmode][value=multi]', dialog).prop('checked', true);
  1841.             $('div.dialog-radio', dialog).hide();
  1842.             $('div.dialog-button button#dialog-copy-button', dialog).hide();
  1843.             $('div.dialog-button button#dialog-edit-button', dialog).hide();
  1844.             $('div.dialog-button button#dialog-exit-button', dialog).hide();
  1845.             dialog.hide();
  1846.             shadow.hide();
  1847.         }

  1848.         dialog = createDialog();
  1849.         shadow = createShadow();
  1850.     }

  1851.     function VCodeDialog(refreshVCode, confirmClick) {
  1852.         var dialog, shadow;

  1853.         function createDialog() {
  1854.             var screenWidth = document.body.clientWidth;
  1855.             var dialogLeft = screenWidth > 520 ? (screenWidth - 520) / 2 : 0;
  1856.             var $dialog_div = $('<div class="dialog" id="dialog-vcode" style="width:520px;top:0px;bottom:auto;left:' + dialogLeft + 'px;right:auto;display:none;visibility:visible;z-index:52"></div>');
  1857.             var $dialog_header = $('<div class="dialog-header"><h3><span class="dialog-header-title"><em class="select-text">提示</em></span></h3></div>');
  1858.             var $dialog_control = $('<div class="dialog-control"><span class="dialog-icon dialog-close icon icon-close"><span class="sicon">x</span></span></div>');
  1859.             var $dialog_body = $('<div class="dialog-body"></div>');
  1860.             var $dialog_body_div = $('<div style="text-align:center;padding:22px"></div>');
  1861.             var $dialog_body_download_verify = $('<div class="download-verify" style="margin-top:10px;padding:0 28px;text-align:left;font-size:12px;"></div>');
  1862.             var $dialog_verify_body = $('<div class="verify-body">请输入验证码:</div>');
  1863.             var $dialog_input = $('<input id="dialog-input" type="text" style="padding:3px;width:85px;height:23px;border:1px solid #c6c6c6;background-color:white;vertical-align:middle;" class="input-code" maxlength="4">');
  1864.             var $dialog_img = $('<img id="dialog-img" class="img-code" style="margin-left:10px;vertical-align:middle;" alt="点击换一张" src="" width="100" height="30">');
  1865.             var $dialog_refresh = $('<a href="javascript:void(0)" style="text-decoration:underline;" class="underline">换一张</a>');
  1866.             var $dialog_err = $('<div id="dialog-err" style="padding-left:84px;height:18px;color:#d80000" class="verify-error"></div>');
  1867.             var $dialog_footer = $('<div class="dialog-footer g-clearfix"></div>');
  1868.             var $dialog_confirm_button = $('<a class="g-button g-button-blue" data-button-id="" data-button-index href="javascript:void(0)" style="padding-left:36px"><span class="g-button-right" style="padding-right:36px;"><span class="text" style="width:auto;">确定</span></span></a>');
  1869.             var $dialog_cancel_button = $('<a class="g-button" data-button-id="" data-button-index href="javascript:void(0);" style="padding-left: 36px;"><span class="g-button-right" style="padding-right: 36px;"><span class="text" style="width: auto;">取消</span></span></a>');

  1870.             $dialog_header.append($dialog_control);
  1871.             $dialog_verify_body.append($dialog_input).append($dialog_img).append($dialog_refresh);
  1872.             $dialog_body_download_verify.append($dialog_verify_body).append($dialog_err);
  1873.             $dialog_body_div.append($dialog_body_download_verify);
  1874.             $dialog_body.append($dialog_body_div);
  1875.             $dialog_footer.append($dialog_confirm_button).append($dialog_cancel_button);
  1876.             $dialog_div.append($dialog_header).append($dialog_body).append($dialog_footer);
  1877.             $('body').append($dialog_div);

  1878.             $dialog_div.dialogDrag();

  1879.             $dialog_control.click(dialogControl);
  1880.             $dialog_img.click(refreshVCode);
  1881.             $dialog_refresh.click(refreshVCode);
  1882.             $dialog_input.keypress(function (event) {
  1883.                 if (event.which == 13)
  1884.                     confirmClick();
  1885.             });
  1886.             $dialog_confirm_button.click(confirmClick);
  1887.             $dialog_cancel_button.click(dialogControl);
  1888.             $dialog_input.click(function () {
  1889.                 $('#dialog-err').text('');
  1890.             });
  1891.             return $dialog_div;
  1892.         }

  1893.         this.open = function (vcode) {
  1894.             if (vcode)
  1895.                 $('#dialog-img').attr('src', vcode.img);
  1896.             dialog.show();
  1897.             shadow.show();
  1898.         }
  1899.         this.close = function () {
  1900.             dialogControl();
  1901.         }
  1902.         dialog = createDialog();
  1903.         shadow = $('div.dialog-shadow');

  1904.         function dialogControl() {
  1905.             $('#dialog-img', dialog).attr('src', '');
  1906.             $('#dialog-err').text('');
  1907.             dialog.hide();
  1908.             shadow.hide();
  1909.         }
  1910.     }

  1911.     $.fn.dialogDrag = function () {
  1912.         var mouseInitX, mouseInitY, dialogInitX, dialogInitY;
  1913.         var screenWidth = document.body.clientWidth;
  1914.         var $parent = this;
  1915.         $('div.dialog-header', this).mousedown(function (event) {
  1916.             mouseInitX = parseInt(event.pageX);
  1917.             mouseInitY = parseInt(event.pageY);
  1918.             dialogInitX = parseInt($parent.css('left').replace('px', ''));
  1919.             dialogInitY = parseInt($parent.css('top').replace('px', ''));
  1920.             $(this).mousemove(function (event) {
  1921.                 var tempX = dialogInitX + parseInt(event.pageX) - mouseInitX;
  1922.                 var tempY = dialogInitY + parseInt(event.pageY) - mouseInitY;
  1923.                 var width = parseInt($parent.css('width').replace('px', ''));
  1924.                 tempX = tempX < 0 ? 0 : tempX > screenWidth - width ? screenWidth - width : tempX;
  1925.                 tempY = tempY < 0 ? 0 : tempY;
  1926.                 $parent.css('left', tempX + 'px').css('top', tempY + 'px');
  1927.             });
  1928.         });
  1929.         $('div.dialog-header', this).mouseup(function (event) {
  1930.             $(this).unbind('mousemove');
  1931.         });
  1932.     }

  1933. })();
复制代码


回复

使用道具 举报

结帖率:100% (45/45)
发表于 2020-4-6 12:53:58 | 显示全部楼层   江苏省徐州市
还是用蓝奏云吧
回复

使用道具 举报

结帖率:100% (11/11)

签到天数: 1 天

 楼主| 发表于 2020-4-6 13:01:39 | 显示全部楼层   浙江省温州市
Bking 发表于 2020-4-6 12:53
还是用蓝奏云吧

我有百度云会员 ,我打算写个直链解析 然后从服务器传回用户那。
回复

使用道具 举报

结帖率:86% (12/14)
发表于 2020-4-6 13:18:39 | 显示全部楼层   广东省佛山市
用5精币求大于50元的东西。看别人肯不肯与你分享吧
回复

使用道具 举报

结帖率:100% (11/11)

签到天数: 1 天

 楼主| 发表于 2020-4-6 14:12:26 | 显示全部楼层   浙江省温州市
ErrorCodes 发表于 2020-4-6 12:43
这样这是一个JS代码看看:

这也太狠了吧 老哥! 哈哈 可惜我搞不明白,我是打算用服务器超级会员 解析好之后 把直链发回给客户Duan  
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 诚聘英才| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 800073686,邮箱:800073686@b.qq.com
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表