GM_wakeup.js is a lightweight, public-domain developer library for userscripts (Tampermonkey, Violentmonkey, Greasemonkey). It acts as a background heartbeat and synchronization utility, designed to manage cross-tab timing or serve as a companion tool for libraries like GM_lock.
GM_wakeup.js 是一个轻量级、公共领域的油猴脚本(Tampermonkey、Violentmonkey、Greasemonkey)开发者工具库。它作为一个后台心跳和同步工具,旨在管理跨标签页的定时任务,或作为 GM_lock 等库的辅助工具。
By checking and updating a shared storage key (__GM_WAKEUP__) every 20 seconds, it ensures that your background scripts stay synchronized and can reliably wake up specific operations without resource-heavy polling loops.
通过每 20 秒检查并更新一次共享存储键值(__GM_WAKEUP__),它能确保您的后台脚本保持同步,并能可靠地唤醒特定操作,而无需编写高能耗的轮询循环。
GM_setValue/GM_getValue) and asynchronous promises (GM.setValue/GM.getValue).
同时支持标准的同步函数(GM_setValue/GM_getValue)和异步 Promise(GM.setValue/GM.getValue)。To use this library, your userscript must grant access to the extension's storage APIs. Ensure your userscript metadata block includes: 要使用此库,您的用户脚本必须授予对扩展存储 API 的访问权限。请确保您的脚本元数据块(Metadata Block)中包含以下内容:
// @grant GM_setValue
// @grant GM_getValue
// OR / 或
// @grant GM.setValue
// @grant GM.getValue
GM_wakeup.start(): Activates the heartbeat loop.
激活心跳循环。GM_wakeup.stop(): Safely halts the background loop.
安全地停止后台循环。