// ==UserScript== // @name Video Player Lock Tool 视频播放锁屏工具 // @namespace http://tampermonkey.net/ // @version 1.2 // @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 // @downloadURL none // ==/UserScript== (function() { 'use strict'; const lockButtonHideDelay = 3000; // 3 seconds delay for button hide let hideButtonTimeout; let isLocked = false; let fullscreenElement = null; // 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 = '30px'; lockButton.style.height = '30px'; 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); // 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.3)'; // Locked State document.body.style.pointerEvents = 'none'; // Disable click events for the entire page. lockButton.style.pointerEvents = 'auto'; // Enable click events for the key. } }); function hideLockButton() { lockButton.style.display = 'none'; } function showLockButton() { lockButton.style.display = 'block'; } function resetHideButtonTimer() { clearTimeout(hideButtonTimeout); hideButtonTimeout = setTimeout(hideLockButton, lockButtonHideDelay); } // Fullscreen change event document.addEventListener('fullscreenchange', function(event) { fullscreenElement = document.fullscreenElement; if (fullscreenElement) { fullscreenElement.appendChild(lockButton); showLockButton(); resetHideButtonTimer(); } else { document.body.appendChild(lockButton); hideLockButton(); clearTimeout(hideButtonTimeout); if (isLocked) { isLocked = false; lockButton.style.backgroundColor = 'gray'; document.body.style.pointerEvents = 'auto'; } } }); // Mouse move event document.addEventListener('mousemove', function() { if (fullscreenElement) { showLockButton(); resetHideButtonTimer(); } }); // Touch start event (for touchscreen devices) document.addEventListener('touchstart', function() { if (fullscreenElement) { showLockButton(); resetHideButtonTimer(); } }); })();