Skip to content

Instantly share code, notes, and snippets.

@basinilya
Created August 21, 2020 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basinilya/0f14fa3e0cfc28e83a94dd612390279e to your computer and use it in GitHub Desktop.
Save basinilya/0f14fa3e0cfc28e83a94dd612390279e to your computer and use it in GitHub Desktop.
/// disable-pageview-api.js
// Based on: https://addons.mozilla.org/firefox/addon/disable-page-visibility/
// License: http://www.opensource.org/licenses/bsd-license.php
(function(){
// visibilitychange events are captured and stopped
document.addEventListener("visibilitychange", function(e) {
e.stopImmediatePropagation();
}, true);
// document.visibilityState always returns false
Object.defineProperty(Document.prototype, "hidden", {
get: function hidden() {
return false;
},
enumerable: true,
configurable: true
});
// document.visibilityState always returns "visible"
Object.defineProperty(Document.prototype, "visibilityState", {
get: function visibilityState() {
return "visible";
},
enumerable: true,
configurable: true
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment