Skip to content

Instantly share code, notes, and snippets.

@Alkarex
Last active August 11, 2023 12:19
Show Gist options
  • Save Alkarex/6dd74cde31568c02f46ac37aab773509 to your computer and use it in GitHub Desktop.
Save Alkarex/6dd74cde31568c02f46ac37aab773509 to your computer and use it in GitHub Desktop.
Greasemonkey user script to stop Web page visibility tracking (e.g. forcing a video to stop if its tab is not in focus)
// ==UserScript==
// @name Stop visibility tracking
// @namespace https://alexandre.alapetite.fr/
// @description Stop Web page visibility tracking (e.g. forcing a video to stop if its tab is not in focus)
// @version 1.0
// @grant none
// @match https://example.net/*
// ==/UserScript==
//NB: You should manually add the Web sites you want to target in your user-specific inclusion list.
window.addEventListener('visibilitychange', function (event) { event.stopImmediatePropagation(); }, true);
window.addEventListener('blur', function (event) { event.stopImmediatePropagation(); }, true);
window.addEventListener('mouseleave', function (event) { event.stopImmediatePropagation(); }, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment