Greasy Fork

Greasy Fork is available in English.

Remove Exam Screen Check Methods

移除icve考试期间切换屏幕检查的方法

当前为 2024-07-02 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Remove Exam Screen Check Methods
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  移除icve考试期间切换屏幕检查的方法
// @author       Yitong233
// @match        *://*.icve.com.cn/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function removeMethods() {
        // 假设这些方法存在于某个对象中,例如 `exam`
        let objNames = ['exam', 'someOtherObject']; // 根据实际情况调整对象名称

        objNames.forEach(name => {
            if (window[name] && typeof window[name] === 'object') {
                let obj = window[name];

                if (obj.winFlag && typeof obj.winFlag === 'function') {
                    obj.winFlag = function() {
                        console.log(name + '.winFlag function removed.');
                    };
                }

                if (obj.check && typeof obj.check === 'function') {
                    obj.check = function() {
                        console.log(name + '.check function removed.');
                    };
                }

                if (obj.onVisibilityChange && typeof obj.onVisibilityChange === 'function') {
                    obj.onVisibilityChange = function() {
                        console.log(name + '.onVisibilityChange function removed.');
                    };
                }

                if (obj.onmouseleaveChange && typeof obj.onmouseleaveChange === 'function') {
                    obj.onmouseleaveChange = function() {
                        console.log(name + '.onmouseleaveChange function removed.');
                    };
                }

                if (obj.isScreen && typeof obj.isScreen === 'function') {
                    obj.isScreen = function() {
                        console.log(name + '.isScreen function removed.');
                    };
                }
            }
        });

        // 如果方法存在于 Vue 组件中
        if (window.Vue) {
            Vue.mixin({
                beforeCreate() {
                    if (this.$options.methods) {
                        if (this.$options.methods.winFlag) {
                            this.$options.methods.winFlag = function() {
                                console.log('winFlag function removed.');
                            };
                        }

                        if (this.$options.methods.check) {
                            this.$options.methods.check = function() {
                                console.log('check function removed.');
                            };
                        }

                        if (this.$options.methods.onVisibilityChange) {
                            this.$options.methods.onVisibilityChange = function() {
                                console.log('onVisibilityChange function removed.');
                            };
                        }

                        if (this.$options.methods.onmouseleaveChange) {
                            this.$options.methods.onmouseleaveChange = function() {
                                console.log('onmouseleaveChange function removed.');
                            };
                        }

                        if (this.$options.methods.isScreen) {
                            this.$options.methods.isScreen = function() {
                                console.log('isScreen function removed.');
                            };
                        }
                    }
                }
            });
        }
    }

    function removeVisibilityChangeListeners() {
        const originalDocumentAddEventListener = document.addEventListener.bind(document);

        document.addEventListener = function(type, listener, options) {
            if (type === 'visibilitychange') {
                console.log('VisibilityChange listener prevented:', listener);
            } else {
                originalDocumentAddEventListener(type, listener, options);
            }
        };

        // 清除已经存在的 visibilitychange 事件监听器
        const events = getEventListeners(document);
        const visibilityChangeListeners = events.visibilitychange || [];
        visibilityChangeListeners.forEach(listener => {
            document.removeEventListener('visibilitychange', listener.listener);
        });

        console.log('All visibilitychange listeners removed');
    }

    // 延迟执行以确保目标脚本已加载
    setTimeout(() => {
        removeMethods();
        removeVisibilityChangeListeners();
    }, 3000);
})();