Idle Detection Bypasser

Give a fake active response to the caller of the Idle Detection API

Från och med 2021-09-24. Se den senaste versionen.

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                Idle Detection Bypasser
// @name:zh             绕过 Idle Detection
// @name:zh-CN          绕过 Idle Detection
// @namespace           https://github.com/flyhaozi
// @version             0.1.0
// @description         Give a fake active response to the caller of the Idle Detection API
// @description:zh      给 Idle Detection API 的调用者一个虚假的 active 响应
// @description:zh-CN   给 Idle Detection API 的调用者一个虚假的 active 响应
// @author              flyhaozi
// @match               https://*/*
// @match               http://*/*
// @grant               none
// ==/UserScript==

(function() {
    'use strict';
    if (!('IdleDetector' in window)) {
        return console.log('Idle Detector is not available.');
    }

    let callback = null;
    window.IdleDetector.prototype.addEventListener = function(type, listener, options) {
        callback = listener;

        console.log('Idle Detection Detected!');
    };
    window.IdleDetector.prototype.start = function() {
        Object.defineProperty(this, 'userState', { value: 'active', writable: false });
        Object.defineProperty(this, 'screenState', { value: 'unlocked', writable: false });
        callback && callback({ currentTarget: this, target: this });

        console.log('Idle Detection Bypassed!');
    };
})();