{"record":{"id":"92231873370ed0a8","repo":"hmjz100/LinkSwift","slug":"br-922318","errorCode":null,"errorMessage":"提示：<br/>请勾选要保存到网盘的文件哦~","messagePattern":"提示：<br/>请勾选要保存到网盘的文件哦~","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"（改）网盘直链下载助手.user.js","lineNumber":6343,"sourceCode":"\t\t\t\t\tconst dialog = await Swal.fire({\r\n\t\t\t\t\t\t...temp.swalDefault,\r\n\t\t\t\t\t\ttitle: \"提示\",\r\n\t\t\t\t\t\thtml: `<div style=\"display:flex;align-items:center;justify-content:center;\">请先切换到&nbsp;&nbsp;<svg class=\"icon\" class=\"icon--D3kMk \" viewBox=\"0 0 1024 1024\" width=\"20\" height=\"20\" fill=\"currentColor\"><use xlink:href=\"#PDSDrag\"></use></svg>&nbsp;<b>列表视图</b>&nbsp;&nbsp;后再获取下载链接哦</div>`,\r\n\t\t\t\t\t\ticon: \"info\",\r\n\t\t\t\t\t\tshowCloseButton: true,\r\n\t\t\t\t\t\tshowDenyButton: true,\r\n\t\t\t\t\t\tconfirmButtonText: `<svg class=\"pl-icon\"><use xlink:href=\"#pl-icon-fa-check\"/></svg> 切换`,\r\n\t\t\t\t\t\tdenyButtonText: `<svg class=\"pl-icon\"><use xlink:href=\"#pl-icon-fa-x-mark\"/></svg> 不要`,\r\n\t\t\t\t\t});\r\n\t\t\t\t\tif (dialog.isConfirmed) {\r\n\t\t\t\t\t\tdocument.querySelector(config.$aliyun.mount.switch).click();\r\n\t\t\t\t\t\treturn message.success(\"提示：<br/>切换为列表视图成功<br/>请再获取一次下载链接吧~\");\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t\tconst selections = temp.main.getSelectedList();\r\n\t\t\t\tif (selections.length === 0) {\r\n\t\t\t\t\tthrow new Error(\"提示：<br/>请勾选要保存到网盘的文件哦~\");\r\n\t\t\t\t}\r\n\t\t\t\tmessage.info(\"提示：<br/>因网盘限制，请保存到自己网盘后再去下载哦~\");\r\n\t\t\t\tawait base.sleep(500);\r\n\t\t\t\tdocument.querySelector(`[class*=\"btn-save--\"]`).click();\r\n\t\t\t});\r\n\t\t\t$doc.on(\"click\", \".listener-api-download.enhance\", async function (e) {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\tconst status = base._EventFactory(e);\r\n\t\t\t\tconst file = {\r\n\t\t\t\t\tindex: status.item.data(\"index\"),\r\n\t\t\t\t\tlink: status.item.data(\"link\"),\r\n\t\t\t\t\tname: status.item.data(\"name\"),\r\n\t\t\t\t\tsize: status.item.data(\"size\") || 0,\r\n\t\t\t\t}\r\n\t\t\t\tbase._resetData(file.index);\r\n\r\n\t\t\t\t// UI 初始化\r\n\t\t\t\tstatus.down_normal.hide();\r","sourceCodeStart":6325,"sourceCodeEnd":6361,"githubUrl":"https://github.com/hmjz100/LinkSwift/blob/417ea5e28a3e1a90339710e17356e9fd22b8a34b/（改）网盘直链下载助手.user.js#L6325-L6361","documentation":"Thrown in the 'save to netdisk' (enhanced save) flow: before simulating a click on the Netdisk save button, the script requires at least one selected item via temp.main.getSelectedList(). Empty selection aborts with this HTML-wrapped popup message, reminding users the workflow is: select files, save to own netdisk, then download.","triggerScenarios":"User clicks the save-to-netdisk button while `temp.main.getSelectedList()` returns []; `selections.length === 0` triggers the throw before the script clicks `[class*=\"btn-save--\"]`.","commonSituations":"User clicks save without ticking any rows; the Netdisk share page uses a view mode whose selection DOM the script can't read (hence the list-view toggle hint right above); stale script after SPA navigation lost selection state.","solutions":["Check at least one file checkbox before clicking save-to-netdisk.","If selection looks present, switch to list view (the script prompts this) and re-select, then retry.","Refresh the page to rebuild script state if selection events stopped registering."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const selections = temp.main.getSelectedList();\nif (!selections || selections.length === 0) { alert('请先勾选要保存的文件'); return; }","typeGuard":"function hasSelection(items) { return Array.isArray(items) && items.length > 0; }","tryCatchPattern":"try { await saveToNetdisk(); } catch (e) { if (String(e.message).includes('请勾选')) { alert('请先勾选文件'); return; } throw e; }","preventionTips":["Check at least one file before clicking save-to-netdisk","Switch to list view if grid-view selection isn't detected","Re-select after page navigation; selection state may reset"],"tags":["userscript","baidu-netdisk","share","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"}