{"record":{"id":"86b15cdd1102648b","repo":"hmjz100/LinkSwift","slug":"br-86b15c","errorCode":null,"errorMessage":"提示：<br/>请勾选要下载的文件哦~","messagePattern":"提示：<br/>请勾选要下载的文件哦~","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"（改）网盘直链下载助手.user.js","lineNumber":6089,"sourceCode":"\t\t\t\tGM_openInTab(config.$baidu.api.getAccessToken, { active: true, insert: true, setParent: true })\r\n\t\t\t\tlet attempts = 0;\r\n\t\t\t\tconst interval = setInterval(() => {\r\n\t\t\t\t\tif (base.getValue(\"baidu_access_token\")) {\r\n\t\t\t\t\t\tclearInterval(interval);\r\n\t\t\t\t\t\ttoken = base.getValue(\"baidu_access_token\")\r\n\t\t\t\t\t}\r\n\t\t\t\t\tattempts++;\r\n\t\t\t\t\tif (attempts > 120) {\r\n\t\t\t\t\t\tclearInterval(interval);\r\n\t\t\t\t\t\tthrow new Error(\"提示：<br/>时间太长，我先撤下啦~\");\r\n\t\t\t\t\t}\r\n\t\t\t\t}, 1000);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// 获取选择的文件列表\r\n\t\t\tconst selects = this.getSelectedList();\r\n\t\t\tif (selects.length === 0) throw new Error(\"提示：<br/>请勾选要下载的文件哦~\");\r\n\r\n\t\t\t$doc.find(\".loading-popup .loading-title\").html(`链接获取中`);\r\n\t\t\t$doc.find(\".loading-popup .swal2-html-container\").html(`<div>正在获取文件对应的下载链接~</div>`);\r\n\r\n\t\t\tlet files = selects.filter(f => !f.isdir);\r\n\t\t\tconst dirs = selects.filter(f => f.isdir);\r\n\t\t\tif (temp.page === \"home\" || temp.page === \"main\") {\r\n\t\t\t\tif (dirs.length > 0) files = files.concat(await this.getFilesList(dirs, token, files.length));\r\n\t\t\t\tif (!files.length) throw new Error(\"提示：<br/>文件夹是空的哦~\");\r\n\r\n\t\t\t\t$doc.find(\".loading-popup .loading-title\").html(`链接获取中`);\r\n\t\t\t\t$doc.find(\".loading-popup .swal2-html-container\").html(`<div>正在获取文件对应的下载链接~</div>`);\r\n\r\n\t\t\t\tfiles = await this.getFilesUrl(files, token).catch(e => {\r\n\t\t\t\t\tif (e instanceof Error) throw e;\r\n\t\t\t\t\tthrow new Error(e?.message || e || \"[百度网盘] 获取文件 URL 失败\");\r\n\t\t\t\t});\r\n\t\t\t} else if (temp.page === \"share\") {\r","sourceCodeStart":6071,"sourceCodeEnd":6107,"githubUrl":"https://github.com/hmjz100/LinkSwift/blob/417ea5e28a3e1a90339710e17356e9fd22b8a34b/（改）网盘直链下载助手.user.js#L6071-L6107","documentation":"Thrown by the Baidu Netdisk (百度网盘) download-link resolver in the userscript when getSelectedList() returns an empty array. The script's download flow requires at least one file or folder to be checked in the Netdisk web UI before it can fetch direct links. The message is HTML-wrapped for display in a SweetAlert2 popup shown to the end user.","triggerScenarios":"User clicks the script's download button while no rows are checked in the Baidu Netdisk file list; the script then executes `const selects = this.getSelectedList(); if (selects.length === 0) throw new Error(\"提示：<br/>请勾选要下载的文件哦~\")`.","commonSituations":"User opens the popup on the Netdisk page but forgets to tick any checkboxes; a UI update or theme change makes the script's checkbox selector miss selections so getSelectedList() returns [] despite visible checks; user clicks download on a fresh page before selecting anything.","solutions":["Tick at least one file or folder checkbox in the Netdisk list before clicking the script's download button.","If items appear selected but the error still shows, refresh the page and re-select (script DOM selectors may be stale).","Switch to list view via the script's settings if grid view selection is not detected, then retry."],"exampleFix":"// user-side: select rows before invoking\nconst selects = this.getSelectedList();\nif (!selects.length) { message.error('请先勾选文件'); return; } // guard instead of reaching the throw","handlingStrategy":"validation","validationCode":"const selects = this.getSelectedList();\nif (!selects || selects.length === 0) { alert('请先勾选要下载的文件'); return; }","typeGuard":"function hasSelection(items) { return Array.isArray(items) && items.length > 0; }","tryCatchPattern":"try { await getLinks(); } catch (e) { if (String(e.message).includes('请勾选')) { alert('请先勾选文件'); return; } throw e; }","preventionTips":["Always check at least one row before clicking the script's download button","Refresh and re-select if the error appears despite visible checks (stale DOM)","Prefer list view for reliable selection detection"],"tags":["userscript","baidu-netdisk","user-input","empty-selection"],"backgroundTag":"empty-selection-before-action","analyzedSha":"417ea5e28a3e1a90339710e17356e9fd22b8a34b","analyzedAt":"2026-09-02T18:13:32.837Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}