进行了一些小修复

This commit is contained in:
2026-08-26 15:29:37 +08:00
parent ae10b3d3fd
commit 562beb15cf
6 changed files with 206 additions and 43 deletions
+8 -14
View File
@@ -228,14 +228,8 @@
// ===== 主流程 =====
function collectCaptchaPayload(sourceEl) {
// 优先从触发按钮所属的下载卡片中查找验证码容器(支持双下载框场景:侧栏+移动端)
var container = null;
if (sourceEl) {
var box = sourceEl.closest('.resource-download-box');
if (box) container = box.querySelector('[data-aksrt-download-captcha]');
}
// 回退到全局查找
if (!container) container = document.querySelector('[data-aksrt-download-captcha]');
const box = sourceEl ? sourceEl.closest('[data-aksrt-download-box]') : null;
const container = box ? box.querySelector('[data-aksrt-download-captcha]') : null;
if (!container) return {};
const out = {};
const keys = [
@@ -252,14 +246,14 @@
return out;
}
function isCaptchaActive() {
const card = document.querySelector('.resource-download-box');
function isCaptchaActive(sourceEl) {
const card = sourceEl ? sourceEl.closest('[data-aksrt-download-box]') : null;
if (!card) return false;
return card.getAttribute('data-captcha') === '1';
}
function ensureCaptchaThen(callback) {
if (!isCaptchaActive()) { callback(); return; }
function ensureCaptchaThen(sourceEl, callback) {
if (!isCaptchaActive(sourceEl)) { callback(); return; }
const state = window.AKSRTCaptchaState;
const scene = state && state.scenes && state.scenes.download;
if (!scene || typeof scene.verify !== 'function') {
@@ -274,7 +268,7 @@
}
function performDownloadRequest(button) {
const card = button.closest('.resource-download-box');
const card = button.closest('[data-aksrt-download-box]');
if (!card) return;
const postId = parseInt(card.getAttribute('data-post-id'), 10);
const sourceIndex = parseInt(button.getAttribute('data-source-index'), 10);
@@ -323,7 +317,7 @@
}
function requestDownload(button) {
ensureCaptchaThen(function () {
ensureCaptchaThen(button, function () {
performDownloadRequest(button);
});
}