您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
try to take over the world!
当前为
// ==UserScript== // @name 百度云文件数量统计 // @namespace http://tampermonkey.net/ // @version 0.4 // @description try to take over the world! // @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 // ==/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<dl; index++) { if(ddList[index].path.indexOf(rootDir) ==-1 && rootDir.indexOf(ddList[index].path) ==-1) continue; (function(index) { var file=ddList[index];//%2B var filepath = file.path.replace(/\+/g,"\%2B"); count=count+GetDirFilsCount(filepath); })(index); } } return count; } function GetDirFilsCount(dirName) { var dfCount=0; $.ajax({ url: dskApi+''+dirName, type: 'get', async: asyncType, timeout: 3000, // 设置超时时间 success: function(data) { var fileLists = data.list; dfCount=GetFilesCount(fileLists); } }); //console.log("☋统计目录为:“"+decodeURIComponent(rootDir)+"” 当前计算总数:"+totalCount+" 用时:" +timeSpan(startTime, new Date())); return dfCount; } GetDirFilsCount(root); alert("统计目录为:“"+decodeURIComponent(rootDir)+"” 当前计算总数:"+totalCount+" 用时:" +timeSpan(startTime, new Date())); })();