// ==UserScript== // @name 全能防切屏防暂停 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 屏蔽切屏检测、焦点检测、页面隐藏检测,视频网课不暂停 // @author You // @match *://*/* // @grant none // ==/UserScript== (function() { 'use strict'; // 1. 强制篡改页面可见状态(核心欺骗) Object.defineProperty(document, 'hidden', { value: false, configurable: true }); Object.defineProperty(document, 'visibilityState', { value: 'visible', configurable: true }); // 2. 劫持事件,拦截所有检测事件 const originAdd = EventTarget.prototype.addEventListener; const banEvents = [ 'visibilitychange', 'blur', 'focusout', 'pagehide', 'mouseleave', 'mouseout' ]; EventTarget.prototype.addEventListener = function(type, cb, opt) { if (banEvents.includes(type)) return; return originAdd.call(this, type, cb, opt); }; // 3. 清空全局焦点监听 window.onblur = null; window.onfocus = null; document.onvisibilitychange = null; console.log("✅ 防切屏脚本已常驻生效!"); })();