feat(pdd-extension): 插件升级至 v1.2.0,增加防休眠心跳、会话主动续期与超时弹窗秒级拦截
1. 新增 content.js 页面级保活引擎,自动注入拼多多商家后台 (mms.pinduoduo.com); 2. 主动防休眠与静默续期:每 2 分钟向 MMS 接口发送轻量只读心跳并派发微动作,主动刷新服务端 PASS_ID 有效期,从根本上阻止空闲弹窗生成; 3. 超时弹窗秒级自动拦截:使用 MutationObserver 实时监听 DOM,毫秒级捕获「当前页面停留时间过长」弹窗并自动点击「刷新」,彻底解决页面挂死导致 Cookie 会话过期被踢出账号的问题; 4. 后台长效平滑刷新:后台标签页静置超 25 分钟自动执行无感安全重载,保障 CSRF Token 与会话 24 小时鲜活; 5. 日志链路打通:将页面防休眠、弹窗拦截与周期刷新事件接入扩展日志控制台。
This commit is contained in:
@@ -380,25 +380,48 @@ chrome.cookies.onChanged.addListener((changeInfo) => {
|
||||
}
|
||||
})
|
||||
|
||||
// 定时任务:每隔 30 分钟进行一次轻量巡检与必要保活上报
|
||||
chrome.alarms.onAlarm.addListener((alarm) => {
|
||||
// 定时任务:每隔 15 分钟进行一次轻量巡检、保活上报与页面 Ping
|
||||
chrome.alarms.onAlarm.addListener(async (alarm) => {
|
||||
if (alarm.name === ALARM_NAME) {
|
||||
syncCookieToServer(false).catch(() => null)
|
||||
|
||||
// 向打开的拼多多商家页面发送保活 Ping
|
||||
try {
|
||||
const tabs = await chrome.tabs.query({ url: '*://mms.pinduoduo.com/*' })
|
||||
for (const tab of tabs) {
|
||||
if (tab.id) {
|
||||
chrome.tabs.sendMessage(tab.id, { action: 'ping_keepalive' }).catch(() => null)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// 忽略查询异常
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 扩展安装或更新时注册定时闹钟
|
||||
chrome.runtime.onInstalled.addListener(() => {
|
||||
chrome.alarms.create(ALARM_NAME, {
|
||||
periodInMinutes: 30,
|
||||
periodInMinutes: 15,
|
||||
})
|
||||
addExtensionLog('info', '扩展安装/更新', '拼多多 Cookie 保活扩展 v1.1.0 后台服务启动')
|
||||
addExtensionLog('info', '扩展安装/更新', '拼多多 Cookie 保活扩展 v1.2.0 (含防退出/弹窗拦截引擎) 已启动')
|
||||
// 首次运行尝试同步一次
|
||||
syncCookieToServer(false).catch(() => null)
|
||||
})
|
||||
|
||||
// 响应来自 popup.js 的前端交互消息
|
||||
// 响应来自 popup.js 与 content.js 的交互消息
|
||||
chrome.runtime.onMessage.addListener((req, _sender, sendResponse) => {
|
||||
if (req.action === 'content_log') {
|
||||
const level = req.level || 'info'
|
||||
const action = req.actionName || req.module || '页面保活'
|
||||
const message = req.message || ''
|
||||
const details = req.details || null
|
||||
addExtensionLog(level, action, message, details).then(() => {
|
||||
sendResponse({ success: true })
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
if (req.action === 'trigger_sync') {
|
||||
syncCookieToServer(true).then(sendResponse).catch((err) => {
|
||||
sendResponse({ success: false, message: String(err) })
|
||||
|
||||
Reference in New Issue
Block a user