// ==UserScript== // @name NBNT: 新版百度网盘共享文件库目录导出工具 // @namespace http://tampermonkey.net/ // @version 0.270 // @description 用于导出百度网盘共享文件库目录和文件列表 // @author UJiN // @license MIT // @match https://pan.baidu.com/disk* // @icon https://nd-static.bdstatic.com/m-static/v20-main/favicon-main.ico // @grant GM_xmlhttpRequest // @grant GM_getValue // @grant GM_setValue // @require https://unpkg.com/xlsx/dist/xlsx.full.min.js // @downloadURL https://update.greasyfork.icu/scripts/520280/NBNT%3A%20%E6%96%B0%E7%89%88%E7%99%BE%E5%BA%A6%E7%BD%91%E7%9B%98%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6%E5%BA%93%E7%9B%AE%E5%BD%95%E5%AF%BC%E5%87%BA%E5%B7%A5%E5%85%B7.user.js // @updateURL https://update.greasyfork.icu/scripts/520280/NBNT%3A%20%E6%96%B0%E7%89%88%E7%99%BE%E5%BA%A6%E7%BD%91%E7%9B%98%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6%E5%BA%93%E7%9B%AE%E5%BD%95%E5%AF%BC%E5%87%BA%E5%B7%A5%E5%85%B7.meta.js // ==/UserScript== (function () { 'use strict'; let directories = []; // 存储解析后的目录数据 let depthSetting = 1; // 默认层数设置 // 添加并发控制池 class RequestPool { constructor() { this.maxConcurrent = config.maxConcurrent; this.currentRequests = 0; this.queue = []; this.requestInterval = config.requestInterval; this.lastRequestTime = 0; } async add(fn) { if (this.currentRequests >= this.maxConcurrent) { await new Promise(resolve => this.queue.push(resolve)); } const now = Date.now(); const timeSinceLastRequest = now - this.lastRequestTime; if (timeSinceLastRequest < this.requestInterval) { await new Promise(resolve => setTimeout(resolve, this.requestInterval - timeSinceLastRequest) ); } this.currentRequests++; this.lastRequestTime = Date.now(); try { return await fn(); } finally { this.currentRequests--; if (this.queue.length > 0) { const next = this.queue.shift(); next(); } } } } // 添加默认配置 const defaultConfig = { maxConcurrent: 2, // 最大并发请求数 requestInterval: 3000, // 请求间隔(毫秒) maxRetries: 3, // 最大重试次数 defaultDepth: 1, // 默认获取层数 indentStyle: 'tree' // 目录分级样式:tree(树形)或 tab(制表符) }; // 获取配置(如果没有则使用默认值) let config = { ...defaultConfig, ...GM_getValue('nbntConfig', {}) }; // 保存配置 function saveConfig() { GM_setValue('nbntConfig', config); } // 创建配置面板 function createConfigPanel() { const panel = document.createElement('div'); panel.style.cssText = ` position: fixed; top: 60px; right: 60px; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 10000; width: 380px; display: none; font-family: "Microsoft YaHei", sans-serif; `; // 添加标签页样式 const style = document.createElement('style'); style.textContent = ` .config-tabs { display: flex; border-bottom: 1px solid #ddd; margin-bottom: 20px; } .config-tab { padding: 8px 16px; cursor: pointer; color: #666; border-bottom: 2px solid transparent; margin-bottom: -1px; } .config-tab.active { color: #06a7ff; border-bottom-color: #06a7ff; } .config-content { display: none; } .config-content.active { display: block; } `; document.head.appendChild(style); panel.innerHTML = `