// ==UserScript== // @name 百度云文件数量统计 // @namespace http://tampermonkey.net/ // @version 0.5 // @description 修订版 // @author You // @match *://pan.baidu.com/disk/home* // @match *://yun.baidu.com/disk/home* // @match *://pan.baidu.com/s/* // @match *://yun.baidu.com/s/* // @match *://pan.baidu.com/share/link* // @match *://yun.baidu.com/share/link* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; /******************** *百度文件数量统计修改版 *2018.08.18 *作品源码来源 https://blog.csdn.net/admans/article/details/80726558 *1.修改版脚本在云盘根目录不会运行,因为太耗费时间 *2.从根目录进入任意子目录后只需刷新页面,获取文件数结束后会页面上方"更多"元素后显示 *3.如果知道目录下有大量子目录请不要运行此脚本,会卡死浏览器 ********************/ /************ *百度查询接口 http://pan.baidu.com/api/list? dir= //查询目录 &num=100000 //分页大小 最大支持99999999999999 默认1000 &page=1 //页码 &order=time //排序属性 &desc=1 //排序顺序 &clienttype=0 &showempty=0 ************/ var root = "/";//指定目录,空取当前目录 var rootDir = "";//取当前目录 var maxPageSize=99999999999999; //最多支持这么多,超过此值报错 var dskApi="https://pan.baidu.com/api/list?order=name&desc=0&showempty=0&web=1&num="+maxPageSize+"&page=1&dir="; var totalCount = 0; var startTime = new Date(); var asyncType=false;//true 异步,false 同步 function timeSpan(stime, etime) { var usedTime = etime - stime; var days = Math.floor(usedTime / (24 * 3600 * 1000)); var leave1 = usedTime % (24 * 3600 * 1000); var hours = Math.floor(leave1 / (3600 * 1000)); var leave2 = leave1 % (3600 * 1000); var minutes = Math.floor(leave2 / (60 * 1000)); var leave3 = leave2 % (60 * 1000); var seconds = Math.round(leave3 / 1000); var time =""; if(days>0) { time+=days+"天"; } if(hours>0) { time+=hours+"小时"; } if(minutes>0) { time+=minutes+"分钟"; } time+=seconds+"秒"; return time; } (function($){ $.getUrlParam = function (name) { var search = document.location.hash; var pattern = new RegExp("[?&]" + name + "\=([^&]+)", "g"); var matcher = pattern.exec(search); var items = null; if (null != matcher) { try { items = decodeURIComponent(decodeURIComponent(matcher[1])); } catch (e) { try { items = decodeURIComponent(matcher[1]); } catch (e) { items = matcher[1]; } } } return items; } })(jQuery); if(rootDir=="") { rootDir = $.getUrlParam("path"); } function GetFilesCount(fileLists) { var count=0; if(fileLists==undefined) { return 0; } if(rootDir == "/") return 0; var ffList=fileLists.filter(function (e) { return e.isdir == 0; }); if(ffList.length > 0 && ffList[0].path.indexOf(rootDir)!=-1) count=ffList.length; totalCount=totalCount+count; var ddList=fileLists.filter(function (e) { return e.isdir == 1; }); var dl=ddList.length; if(dl>0) { for (var index=0; index