diff --git a/routes/index.js b/routes/index.js index 92ab9be..926d214 100644 --- a/routes/index.js +++ b/routes/index.js @@ -84,13 +84,20 @@ async function handle(url, uuid, areaName, htmlStr, cookie, userAgent) { // 方案1 通过监听cookie 判断cookie是否生成 const superSetCookie = cookieJar.setCookie; + let generateCookieKey = null; // 设置 setCookie 代理 cookieJar.setCookie = function (cookie, currentUrl, options, callback) { console.debug(`${uuid};正在设置 Cookie:`, cookie, currentUrl); let call = superSetCookie.call(this, cookie, currentUrl, options, callback); - // 设置标志可取标志 - if (cookie.includes('P=')) { + // 根据瑞树6 cookie 特性 截取 `enable_XXXXXXXXXXXX=true` XXXXXXXX 为即将生成的 cookie key + if (generateCookieKey != null && cookie.includes(generateCookieKey)) { window[uuid] = true + console.debug('匹配---->', cookie) + } + let match = cookie.match(/enable_(.*?)=true/); + if (match) { + generateCookieKey = match[1]; + console.debug('设置 匹配---->', generateCookieKey) } return call; };