Keeps Stripchat visible optimally (Combines best of v1.1 & v1.2)
// ==UserScript==
// @name Stripchat Always Focus
// @namespace http://tampermonkey.net/
// @version 1.3
// @description Keeps Stripchat visible optimally (Combines best of v1.1 & v1.2)
// @author Nam
// @match *://stripchat.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function () {
'use strict';
// Ưu điểm từ bản v1.2: Ghi đè bằng getter tự nhiên
Object.defineProperty(document, 'hidden', {
configurable: true,
get: () => false
});
Object.defineProperty(document, 'visibilityState', {
configurable: true,
get: () => 'visible'
});
Document.prototype.hasFocus = function () {
return true;
};
// Ưu điểm từ bản v1.1: Chặn tín hiệu gửi đến trang web khi đổi tab
const visibilityEvents = ['visibilitychange', 'webkitvisibilitychange'];
for (let eventName of visibilityEvents) {
window.addEventListener(eventName, function(event) {
event.stopImmediatePropagation();
}, true);
document.addEventListener(eventName, function(event) {
event.stopImmediatePropagation();
}, true);
}
window.addEventListener('blur', function(event) {
if (event.target === window || event.target === document) {
event.stopImmediatePropagation();
}
}, true);
})();