tricks the website into thinking the tab is always active and visible
// ==UserScript==
// @name Stripchat Always Focus
// @namespace http://tampermonkey.net/
// @version 1.0
// @description tricks the website into thinking the tab is always active and visible
// @author Nam
// @match *://stripchat.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
Object.defineProperty(document, 'hidden', { value: false, writable: false });
Object.defineProperty(document, 'visibilityState', { value: 'visible', writable: false });
Document.prototype.hasFocus = function() { return true; };
const blockEvents = ['visibilitychange', 'webkitvisibilitychange', 'blur', 'mouseleave'];
for (let eventName of blockEvents) {
window.addEventListener(eventName, function(event) {
event.stopImmediatePropagation();
}, true);
document.addEventListener(eventName, function(event) {
event.stopImmediatePropagation();
}, true);
}
})();