Emulate sendBeacon on Perplexity.ai

Emulate sendBeacon if beacon.enabled is disabled in Firefox for https://*.perplexity.ai/*

作者
ohmylock
今日安裝
0
安裝總數
0
評價
0 0 0
版本
1.0
建立日期
2025-09-29
更新日期
2025-09-29
尺寸
1.2 KB
授權條款
MIT
腳本執行於

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

  1. Install a userscript manager such as Tampermonkey or Greasemonkey.
  2. Install this userscript from Greasy Fork.
  3. 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.