double-touched to enter fullscreen

I AM THE WORLD

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         double-touched to enter fullscreen
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  I AM THE WORLD
// @author       You
// @match        *://*.douyin.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=douyin.com
// @grant        GM_registerMenuCommand
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    let ref_url = 'https://www.douyin.com/?is_from_mobile_home=1&recommend=1';
    if(window.location.href == 'https://www.douyin.com/home') {
        window.location.href = ref_url;
    };

     function toggleFullscreen() {
        let videoElement = document.querySelector("video"); // Target the video element

        if (!document.fullscreenElement) {
            if (videoElement.requestFullscreen) {
                videoElement.requestFullscreen();
            } else if (videoElement.mozRequestFullScreen) { // Firefox
                videoElement.mozRequestFullScreen();
            } else if (videoElement.webkitRequestFullscreen) { // Chrome, Safari, Opera
                videoElement.webkitRequestFullscreen();
            } else if (videoElement.msRequestFullscreen) { // IE/Edge
                videoElement.msRequestFullscreen();
            }
        } else {
            if (document.exitFullscreen) {
                document.exitFullscreen();
            } else if (document.mozCancelFullScreen) { // Firefox
                document.mozCancelFullScreen();
            } else if (document.webkitExitFullscreen) { // Chrome, Safari, Opera
                document.webkitExitFullscreen();
            } else if (document.msExitFullscreen) { // IE/Edge
                document.msExitFullscreen();
            }
        }
    }

    // Register the menu command to toggle fullscreen
    GM_registerMenuCommand('Toggle Fullscreen', toggleFullscreen);


    // Hide the DanMu Data
    const observer = new MutationObserver(() => {
    document.querySelectorAll('.danmu').forEach(element => {
        element.style.display = 'none';
        });

    });

// Configure the observer to watch for changes in the entire document
    observer.observe(document, {
        childList: true,
        subtree: true,
    });

   window.onload = () => {
      let btn = document.createElement("button");
        btn.innerHTML = "Let's Go";
        btn.id = "fullscreen";
        btn.style.position = "fixed";  // Stays in place while scrolling
        btn.style.top = "10px";        // Distance from the top
        btn.style.left = "10px";       // Distance from the left
        btn.style.padding = "10px 20px";
        btn.style.backgroundColor = "blue";
        btn.style.color = "white";
        btn.style.border = "none";
        btn.style.borderRadius = "5px";
        btn.style.cursor = "pointer";
        btn.style.zIndex = "9999"; // Ensures the button is in the front layer

        // Add click event to redirect
        btn.onclick = function () {
            document.documentElement.webkitRequestFullscreen();
            document.getElementById('fullscreen').style.display = 'none'
        };

        // Append button to the body
        document.body.appendChild(btn);
   }
})();