hmjz100/LinkSwift · warning · Error

提示:<br/>请勾选要下载的文件哦~

Error message

提示:<br/>请勾选要下载的文件哦~

What it means

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.

Source

Thrown at (改)网盘直链下载助手.user.js:6089

				GM_openInTab(config.$baidu.api.getAccessToken, { active: true, insert: true, setParent: true })
				let attempts = 0;
				const interval = setInterval(() => {
					if (base.getValue("baidu_access_token")) {
						clearInterval(interval);
						token = base.getValue("baidu_access_token")
					}
					attempts++;
					if (attempts > 120) {
						clearInterval(interval);
						throw new Error("提示:<br/>时间太长,我先撤下啦~");
					}
				}, 1000);
				return;
			}

			// 获取选择的文件列表
			const selects = this.getSelectedList();
			if (selects.length === 0) throw new Error("提示:<br/>请勾选要下载的文件哦~");

			$doc.find(".loading-popup .loading-title").html(`链接获取中`);
			$doc.find(".loading-popup .swal2-html-container").html(`<div>正在获取文件对应的下载链接~</div>`);

			let files = selects.filter(f => !f.isdir);
			const dirs = selects.filter(f => f.isdir);
			if (temp.page === "home" || temp.page === "main") {
				if (dirs.length > 0) files = files.concat(await this.getFilesList(dirs, token, files.length));
				if (!files.length) throw new Error("提示:<br/>文件夹是空的哦~");

				$doc.find(".loading-popup .loading-title").html(`链接获取中`);
				$doc.find(".loading-popup .swal2-html-container").html(`<div>正在获取文件对应的下载链接~</div>`);

				files = await this.getFilesUrl(files, token).catch(e => {
					if (e instanceof Error) throw e;
					throw new Error(e?.message || e || "[百度网盘] 获取文件 URL 失败");
				});
			} else if (temp.page === "share") {

View on GitHub (pinned to 417ea5e28a)

Solutions

  1. Tick at least one file or folder checkbox in the Netdisk list before clicking the script's download button.
  2. If items appear selected but the error still shows, refresh the page and re-select (script DOM selectors may be stale).
  3. Switch to list view via the script's settings if grid view selection is not detected, then retry.

Example fix

// user-side: select rows before invoking
const selects = this.getSelectedList();
if (!selects.length) { message.error('请先勾选文件'); return; } // guard instead of reaching the throw
Defensive patterns

Strategy: validation

Validate before calling

const selects = this.getSelectedList();
if (!selects || selects.length === 0) { alert('请先勾选要下载的文件'); return; }

Type guard

function hasSelection(items) { return Array.isArray(items) && items.length > 0; }

Try / catch

try { await getLinks(); } catch (e) { if (String(e.message).includes('请勾选')) { alert('请先勾选文件'); return; } throw e; }

Prevention

When it happens

Trigger: 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/>请勾选要下载的文件哦~")`.

Common situations: 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.

Related errors


AI-assisted analysis of hmjz100/LinkSwift@417ea5e28a (2026-09-02). Data as JSON: /api/errors/86b15cdd1102648b. Report an issue: GitHub.