Block Visibility Detections

block page/tab visibility change detections

Ajankohdalta 27.11.2020. Katso uusin versio.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Block Visibility Detections
// @namespace    http://twitter.com/D4D4K
// @version      0.1
// @description  block page/tab visibility change detections
// @author       Dadak
// @match      *://*/*
// @grant        none
// ==/UserScript==

/*jshint esversion: 6 */

var s = document.createElement('script');
s.textContent =
  '(function() {' +
  'var a = Node.prototype.addEventListener;' +
  'Node.prototype.addEventListener = function(e) {' +
  "if (e !== 'visibilitychange' && e !== 'webkitvisibilitychange') {" +
  'a.apply(this, arguments)' +
  '}}' +
  '})()'
;
(document.head || document.documentElement).appendChild(s);
s.remove();

Object.defineProperty(document, "hidden", { value : false});

for (var event_name of ["visibilitychange", "webkitvisibilitychange", "blur"]) {
  window.addEventListener(event_name, function(event) {
        event.stopImmediatePropagation();
    }, true);
}