TikTok No Pause on Tab Switch

Prevent TikTok from pausing videos when switching tabs

目前为 2025-02-05 提交的版本。查看 最新版本

// ==UserScript==
// @name         TikTok No Pause on Tab Switch
// @namespace    http://tampermonkey.net/
// @version      2025-02-05
// @description  Prevent TikTok from pausing videos when switching tabs
// @author       You
// @match        https://www.tiktok.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tiktok.com
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    Object.defineProperty(document, "visibilityState", {
        get: () => "visible"
    });

    Object.defineProperty(document, "hidden", {
        get: () => false
    });

    document.addEventListener("visibilitychange", (event) => {
        event.stopImmediatePropagation();
    }, true);

})();