hmjz100/LinkSwift · error · Error
错误:<br/>无法提取分享 ID~
Error message
错误:<br/>无法提取分享 ID~
What it means
On the Quark share page, the script tries three ways to derive the share ID (pwd_id): unsafeWindow.factStat.ut.baseParams.pwd_id, factStat.wa.customStatParams.pwd_id, then a regex on location.pathname for /s/<id> or /share/<id>. If all fail it throws this error because subsequent getLink calls require pwd_id. It guards against Quark page-structure changes breaking the extraction.
Source
Thrown at (改)网盘直链下载助手.user.js:8535
}
temp.links = [data, {
isFolder: v => v.file === false,
getFileName: v => v.file_name,
getFileSize: v => v.size,
getFileLink: v => v.download_url,
convert: {
aria2: `--header "User-Agent:${config.$quark.api.ua.downloadLink}" --header "Referer:https://${location.host}/" --header "Cookie:${document.cookie}"`,
curl: `-A "${config.$quark.api.ua.downloadLink}" -e "https://${location.host}/" -b "${document.cookie}"`,
bitcomet: `user_agent=${encodeURIComponent(config.$quark.api.ua.downloadLink)}&refer=${encodeURIComponent(`https://${location.host}/`)}&cookie=${encodeURIComponent(document.cookie)}`
},
tooltip: config.$quark.dom
}];
base.showMainDialog(config.base.dom.button[temp.mode].title, base.generateDOM(temp.links), config.base.dom.button[temp.mode].footer);
} else if (temp.page === "share") {
const pwd_id = unsafeWindow.factStat?.ut?.baseParams?.pwd_id || // fast
unsafeWindow.factStat?.wa?.customStatParams?.pwd_id || // drive
location.pathname.match(/^\/(?:s|share)\/([a-zA-Z0-9]+)/)?.[1]; // 兜底
if (!pwd_id) throw new Error("错误:<br/>无法提取分享 ID~");
const data = [];
const batchSize = 15;
let proc = 0;
selects = selects.filter(item => item.file === true)
for (let i = 0; i < selects.length; i += batchSize) {
// 获取当前批次文件
const batch = selects.slice(i, i + batchSize);
const fids = batch.map(item => item.fid);
const fids_token = batch.map(item => item.share_fid_token);
// 发起请求获取链接
const res = await base.post(config.$quark.api.getLink, { "fids": fids, "fids_token": fids_token, pwd_id, "stoken": batch[0].stoken }, { "Content-Type": "application/json", "Cookie": String(document.cookie), "User-Agent": config.$quark.api.ua.downloadLink });
if (!res || res.code !== 0 || !res.data) {
if (res.code == 31001) throw new Error("提示:<br/>请先登录网盘~<br/>代码:" + res.code);
if (res.code == 23018) {
const fid = res.message?.match(/\[([a-f0-9]{32})\]/)?.[1];
const item = batch.find(item => item.fid === fid);
View on GitHub (pinned to 417ea5e28a)
Solutions
- Open the share via a canonical https://pan.quark.cn/s/<id> URL and retry
- Check window.factStat in the console to see if the globals moved and update the extraction paths
- Update the userscript to a version matching the current Quark page structure
Example fix
// before const pwd_id = unsafeWindow.factStat?.ut?.baseParams?.pwd_id || location.pathname.match(/^\/(?:s|share)\/([a-zA-Z0-9]+)/)?.[1]; // after const pwd_id = unsafeWindow.factStat?.ut?.baseParams?.pwd_id || unsafeWindow.__INITIAL_STATE__?.share?.pwd_id || location.pathname.match(/^\/(?:s|share)\/([a-zA-Z0-9]+)/)?.[1];
Defensive patterns
Strategy: validation
Validate before calling
const pwd_id = location.pathname.match(/^\/(?:s|share)\/([a-zA-Z0-9]+)/)?.[1]; if (!pwd_id) { alert('请在分享页 (pan.quark.cn/s/...) 使用本功能'); return; } Type guard
function hasPwdId(w){ return !!(w?.factStat?.ut?.baseParams?.pwd_id || w?.factStat?.wa?.customStatParams?.pwd_id); } Try / catch
try { await exportLinks() } catch (e) { if (String(e.message).includes('无法提取分享 ID')) { location.assign('https://pan.quark.cn/s/' + prompt('粘贴分享ID')); } else throw e; } Prevention
- Only run the export from a canonical /s/<id> share URL
- Hard-reload the share page so SPA state and stats globals are fresh
- Check window.factStat in console after Quark updates
- Keep the userscript updated for page-structure changes
When it happens
Trigger: Clicking the script's download button on a URL that is neither /s/<id> nor /share/<id>, or Quark removing/renaming the factStat global so both stat-based extractions return undefined.
Common situations: Running the script on the wrong page (home/drive page routed as 'share'); Quark updated its stats SDK breaking factStat; accessing a share via an unusual entry URL or SPA state without a path change.
Related errors
- 23018
- 提示:<br/>获取链接失败了~<br/>${res.code ? res.code : ""} ${res.messa
- GreaseMonkey 兼容 XMLHttpRequest 不可用。
- [百度网盘] 获取令牌失败
- 提示:<br/>时间太长,我先撤下啦~
AI-assisted analysis of hmjz100/LinkSwift@417ea5e28a (2026-09-02).
Data as JSON: /api/errors/15956b0ef80495ce.
Report an issue: GitHub.