Video Player Lock Tool 视频播放锁屏工具

视频全屏锁屏防误触 Locks the screen until a key is clicked.

目前为 2023-08-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         Video Player Lock Tool 视频播放锁屏工具
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  视频全屏锁屏防误触 Locks the screen until a key is clicked.
// @author       Hui Fei 会飞
// @match        *://*.youku.com/*
// @match        *://*.iqiyi.com/*
// @match        *://*.iq.com/*
// @match        *://v.qq.com/*
// @match        *://m.v.qq.com/*
// @match        *://*.tudou.com/*
// @match        *://*.youtube.com/*
// @match        *://*.bilibili.com/*
// @grant        none
// @license      MIT License
// ==/UserScript==

(function() {
    'use strict';

    // Create the key-shaped lock element
    const lockButton = document.createElement('div');
    lockButton.id = 'lockButton';
    lockButton.style.position = 'fixed';
    lockButton.style.left = '0';
    lockButton.style.top = '50%';
    lockButton.style.transform = 'translateY(-50%)';
    lockButton.style.width = '20px';
    lockButton.style.height = '20px';
    lockButton.style.backgroundColor = 'rgba(128, 128, 128, 0.3)';
    lockButton.style.borderRadius = '50%';
    lockButton.style.cursor = 'pointer';
    lockButton.style.zIndex = '99999';
    lockButton.style.display = 'none'; // Initially hidden
    document.body.appendChild(lockButton);

    let isLocked = false;

    // Lock Screen Button Click Event
    lockButton.addEventListener('click', function(event) {

        if (isLocked) {
            isLocked = false;
            lockButton.style.backgroundColor = 'gray'; // Unlocked state.
            document.body.style.pointerEvents = 'auto'; // Enable click events for the page.
        } else {
            isLocked = true;
            lockButton.style.backgroundColor = 'rgba(0, 128, 0, 0.1)'; // Locked State
            document.body.style.pointerEvents = 'none'; // Disable click events for the entire page.
            lockButton.style.pointerEvents = 'auto'; // Enable click events for the key.
        }
    });

    // Fullscreen change event
    document.addEventListener('fullscreenchange', function(event) {
        const fullscreenElement = document.fullscreenElement;
        if (fullscreenElement) {
            fullscreenElement.appendChild(lockButton);
            lockButton.style.display = 'block'; // Show the lock button when in fullscreen mode
        } else {
            document.body.appendChild(lockButton);
            lockButton.style.display = 'none'; // Hide the lock button when not in fullscreen mode
            if (isLocked) { // If the screen is locked, unlock it when exiting fullscreen
                isLocked = false;
                lockButton.style.backgroundColor = 'gray';
                document.body.style.pointerEvents = 'auto';
            }
        }
    });

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址