fix(pugongying): 修复小红书短链接解析失败的问题
xhslink.com 短链接对 HEAD 请求返回 404,且重定向 URL 在 HTML body 的 href 中而非 HTTP 302 header。改用 GET 请求并从响应体中解析真实 URL。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
99d16f1f70
commit
e494f32b14
@ -243,10 +243,19 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GM_xmlhttpRequest({
|
GM_xmlhttpRequest({
|
||||||
method: "HEAD",
|
method: "GET",
|
||||||
url,
|
url,
|
||||||
onload(res) {
|
onload(res) {
|
||||||
resolve(res.finalUrl || url);
|
if (res.finalUrl && res.finalUrl !== url) {
|
||||||
|
resolve(res.finalUrl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const match = res.responseText && res.responseText.match(/href="([^"]+)"/);
|
||||||
|
if (match) {
|
||||||
|
resolve(match[1].replace(/&/g, "&"));
|
||||||
|
} else {
|
||||||
|
resolve(url);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onerror() {
|
onerror() {
|
||||||
resolve(url);
|
resolve(url);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user