Douyin Anti Pause

阻止抖音网页端长时间无操作自动暂停

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

Advertisement:

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

Advertisement:

// ==UserScript==
// @name         Douyin Anti Pause
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  阻止抖音网页端长时间无操作自动暂停
// @match        *://www.douyin.com/*
// @match        *://live.douyin.com/*
// @match        *://*.douyin.com/*
// @run-at       document-start
// @grant        unsafeWindow
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    console.log("Douyin Anti Pause 已加载");

    const docProto = Document.prototype;

    try {
        Object.defineProperty(docProto, 'hidden', {
            configurable: true,
            get: () => false
        });

        Object.defineProperty(docProto, 'visibilityState', {
            configurable: true,
            get: () => 'visible'
        });

        document.hasFocus = () => true;

        console.log("visibility hook 成功");
    } catch (e) {
        console.error("visibility hook 失败", e);
    }

})();