Anti-Visibility Cloak

Force pages to always think the tab is visible/focused; optionally spoofs mouse as always "in page" and blocks exit/enter intent; shows a tiny popup when a visibility or mouse check is detected

作者
Spinfal
日安装量
0
总安装量
10
评分
0 0 0
版本
1.2.1
创建于
2025-08-26
更新于
2025-09-02
大小
29.6 KB
许可证
GPL-3.0-or-later
适用于
所有网站

always visible (Anti-Visibility Cloak)

forces sites to always think the tab is visible and focused. it blocks or rewrites common ways pages detect tab visibility/focus and can optionally show a tiny popup when those checks happen.


features

1) overrides core visibility & focus

  • document.visibilityState"visible"
  • document.hiddenfalse
  • legacy props (webkitVisibilityState, mozHidden, msHidden, etc.) → coerced to visible
  • document.hasFocus()true
  • optional: light hardening in strict mode to resist site re-patching

2) intercepts visibility & lifecycle events

  • wraps/neutralizes: visibilitychange, webkitvisibilitychange, mozvisibilitychange, msvisibilitychange
  • covers lifecycle: pagehide, pageshow, freeze, resume
  • focus pipeline: blur, focus, focusin, focusout (configurable; global blur/focusout can be swallowed to stop “window blur” probes)
  • property handlers (onvisibilitychange, onblur, etc.) are wrapped too

all wrapped handlers observe a “document is visible” state.

3) optional mouse presence spoof

  • periodic synthetic mousemove (and optional pointermove) with subtle jitter
  • blocks classic enter/exit-intent traps on global targets (window/document/html/body)
  • optional micro scroll nudge (off by default)

4) configurable toast notifications

  • tiny popup (bottom-right) when checks are registered and/or invoked
  • fades quickly and removes itself from the DOM

5) self-defense & timing

  • runs at @run-at document-start and in @all-frames
  • re-applies key descriptors if a site tries to revert them (observer + optional paranoid loop)
  • optional timer smoothing for throttled tabs (requestAnimationFrame / requestIdleCallback) — off by default

6) page-realm coverage

  • mirrors core patches inside the page’s own JS realm to catch libs that cache natives early (CSP permitting)

7) low-friction controls (optional)

  • exposes a randomized per-load window API (name and method keys change each page load) for toggling strict/paranoid modes and viewing simple stats (console logs the mapping once). can be disabled.

use cases

  • stop videos/players from pausing when backgrounded
    • useful for discord's quest videos visibility checks
  • prevent analytics/ads from inferring tab background state
  • QA/debugging pages that rely on the Visibility API

quick config (inside the script)

  • strictMode: harder to undo patches (off by default)
  • paranoidMode: periodic re-apply (off by default)
  • pageRealmPatch: also patch in page realm (on)
  • patchTimers: smooth rAF/idle in background (off)
  • patchPointerCapture: soften pointer-capture-based exit intent (on)
  • notify: choose when the popup appears
  • mouse: tune presence spoofing and enter/exit filtering
  • focus.blockGlobalBlur: swallow global blur/focusout probes (on)

compatibility

  • tested on violentmonkey, should work on tampermonkey; no dependencies
  • designed to be conservative by default; flip on strict/paranoid only if needed

verify it’s working


privacy

no network calls, no external code resources. all logic runs locally.


PERFORMANCE DISCLAIMER

this script may keep some backgrounded tabs busier than normal, since it prevents browsers from pausing work when a tab isn’t visible. this isn't a bug or feature; it is an unintended side-effect of the browser and website thinking that you are still viewing each tab. however, this will NOT impact your browser's memory-saving features (i.e., chromium's Memory Saver).

possible effects

  • higher cpu/battery use if sites keep running animations, ads, or analytics in the background
  • synthetic mouse events may trigger site handlers more often
  • “paranoid” or “strict” modes re-apply patches more aggressively
  • timer smoothing (patchTimers) can wake tabs up more often

safe configs

  • low-impact (default-ish)

    • strictMode: false
    • paranoidMode: false
    • patchTimers: false
    • mouse.fakeIntervalMs: 30000+
    • notify: mostly off
  • video keeps playing, stay efficient

    • focus.blockGlobalBlur: true
    • pageRealmPatch: true
    • mouse.fakeIntervalMs: 30000–45000
    • leave patchTimers: false
  • maximum stickiness (expect more cpu/battery)

    • strictMode: true
    • paranoidMode: true
    • patchTimers: true
    • mouse.alsoPointerMove: true

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址