(id)
| 440 | let _hitTimer = null; |
| 441 | let _hitBuffer = {}; |
| 442 | const _hit = (id) => { |
| 443 | _hitBuffer[id] = (_hitBuffer[id] || 0) + 1; |
| 444 | if (_hitTimer) return; |
| 445 | _hitTimer = setTimeout(() => { |
| 446 | let buf = _hitBuffer; _hitBuffer = {}; _hitTimer = null; |
| 447 | chrome.storage.local.get(PAGE_MONKEY_LOCAL_STORAGE_KEY, resps => { |
| 448 | let raw = resps && resps[PAGE_MONKEY_LOCAL_STORAGE_KEY]; |
| 449 | if (!raw) return; |
| 450 | try { |
| 451 | let arr = JSON.parse(raw); |
| 452 | arr.forEach(cm => { if (buf[cm.id]) cm.mHits = (cm.mHits || 0) + buf[cm.id]; }); |
| 453 | let data = {}; data[PAGE_MONKEY_LOCAL_STORAGE_KEY] = JSON.stringify(arr); |
| 454 | chrome.storage.local.set(data); |
| 455 | } catch (e) {} |
| 456 | }); |
| 457 | }, 1500); |
| 458 | }; |
| 459 | |
| 460 | /* ================== 启动入口(按 runAt 触发) ================== */ |
| 461 | const start = (params) => { |
no test coverage detected