Emulate sendBeacon on Perplexity.ai
Description
This userscript emulates the navigator.sendBeacon
method on websites under the https://.perplexity.ai/ domain. In recent Firefox versions, when the internal beacon.enabled
setting is disabled, the native sendBeacon
method does not function, causing issues with site features relying on it to send data asynchronously in the background.
The script overrides navigator.sendBeacon
by using the modern fetch
API with the keepalive: true
option, closely mimicking the behavior of the original sendBeacon
. This allows sending asynchronous POST requests without blocking page unload and with a high probability that data will be sent when the tab or page closes.
Features
- Works only on https://.perplexity.ai/ sites
- Emulates sendBeacon using
fetch
with keepalive
- No need to manually change browser settings (no enabling beacon.enabled in about:config)
- Ensures site functionality remains intact even if the browser disables sendBeacon
- Small, self-contained script without external dependencies
Why use this script?
Firefox sometimes disables the Beacon API by default (when beacon.enabled
is false), breaking functionality on sites relying on sendBeacon
for analytics, logging, or telemetry. This script locally emulates sendBeacon
on the site level, restoring functionality without compromising security or requiring user intervention in browser configuration.
Installation
- Install a userscript manager such as Tampermonkey or Greasemonkey.
- Install this userscript from Greasy Fork.
- Use https://*.perplexity.ai/ as usual — the
sendBeacon
method will work correctly even if disabled by the browser.
License and Security
This script is open source and contains no malicious code. The full source code is available for review before installation. It does not load external resources or send data to third parties.