Douyin Anti Pause

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

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 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!)

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.

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

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);
    }

})();