Skip to content

Instantly share code, notes, and snippets.

@kindlychung
Created October 6, 2023 15:43
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 kindlychung/3a21a1114c4c7cca084f2dc9cca32935 to your computer and use it in GitHub Desktop.
Save kindlychung/3a21a1114c4c7cca084f2dc9cca32935 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