hmjz100/LinkSwift · error · Error
[光鸭云盘] 获取分享令牌失败
Error message
[光鸭云盘] 获取分享令牌失败
What it means
Wrapper error in the 光鸭云盘 (Guangya Cloud) module's addPageListener: on page load it eagerly calls getShareToken(true) to pre-fetch a share token, and any non-Error rejection is re-thrown as '[光鸭云盘] 获取分享令牌失败'. The catch runs fire-and-forget (no await), so this error typically surfaces as an unhandled rejection on page load.
Source
Thrown at (改)网盘直链下载助手.user.js:7840
base.registerMenuCommand();
if (config.base.num === base.getValue("setting_init").code || config.base.license === base.getValue("setting_init").license) {
this.addButton();
} else {
this.addInitButton();
}
this.addPageListener();
},
};
/**
* 光鸭云盘
* @author hmjz100
*/
const $guangya = {
addPageListener() {
this.getShareToken(true).catch(e => {
if (e instanceof Error) throw e;
throw new Error(e?.message || e || "[光鸭云盘] 获取分享令牌失败");
});
$doc.on("click", ".listener-api-download.enhance", async function (e) {
e.preventDefault();
const status = base._EventFactory(e);
const file = {
index: status.item.data("index"),
link: status.item.data("link"),
name: status.item.data("name"),
size: status.item.data("size") || 0,
}
base._resetData(file.index);
// UI 初始化
status.down_normal.hide();
status.down_enhance.hide();
status.down_idm.hide();
status.link_message.hide();
status.link_copy.hide();
View on GitHub (pinned to 417ea5e28a)
Solutions
- Verify the share link is still valid and opens correctly in the browser
- Reload the page to retrigger getShareToken with fresh state
- Check console for the original rejection value to find the true cause (share id, captcha, or network)
- Login/refresh captcha state in the userscript if the underlying flow reports auth problems
Example fix
// fire-and-forget with logging
this.getShareToken(true).catch(e => {
console.warn("[光鸭云盘] 分享令牌预取失败:", e);
}); Defensive patterns
Strategy: fallback
Validate before calling
const shareId = extractShareId(location);
if (!shareId) { console.warn('无有效 shareId,跳过分享令牌预取'); return; } Type guard
function isError(e) { return e instanceof Error; } Try / catch
try { await getShareToken(true); } catch (e) { shareTokenPromise = null; console.warn('分享令牌预取失败,将在下载时重试:', e); } Prevention
- Verify share links are valid before prefetching
- Treat prefetch failure as non-fatal and fetch lazily on demand
- Log original rejection payloads
- Retry lazily on user download click instead of at page load
When it happens
Trigger: Opening a Guangya share page triggers addPageListener -> getShareToken(true); if the underlying token flow rejects with a non-Error (raw JSON error, string, undefined), the wrapper fires — even before the user clicks download.
Common situations: Share ID missing/invalid on the page so token fetch fails; share expired or cancelled by owner; captcha token missing causing the internal flow to reject with a non-Error; network error surfacing as a non-Error rejection.
Related errors
- [天翼云盘] 获取文件 URL 失败
- [迅雷云盘] 获取文件 URL 失败
- 提示:<br/>获取分享令牌失败,${res.msg ? "服务器说:" + res.msg + "。" : "刷新后再
- 112
- 提示:<br/>获取下载链接失败,刷新网页后再试试吧~
AI-assisted analysis of hmjz100/LinkSwift@417ea5e28a (2026-09-02).
Data as JSON: /api/errors/f45652faccea3fe1.
Report an issue: GitHub.