Disable close current page

disable close current page when open devtools.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Disable close current page
// @namespace    http://tampermonkey.net/
// @version      2024-10-18
// @description  disable close current page when open devtools.
// @author       You
// @license MIT
// @match        *://*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=rawchat.cn
// @grant        none
// ==/UserScript==

(function() {

        // 保存原始的 window.close 方法
        window.close.originalClose = window.close;

        // 重写 window.close 方法
        window.close = function() {
            // 在关闭之前执行的调试代码
            console.log('window.close 被调用,准备关闭窗口。');
            debugger; // 触发调试器

            // 调用原始的 window.close 方法
            window.close.originalClose();
        };
    // Your code here...
    // 保存原始的 setInterval 方法
    const originalSetInterval = window.setInterval;

    // 重写 setInterval 方法
    window.setInterval = function(callback, delay, ...args) {
        console.log('setInterval 被调用,延迟时间:', delay, '参数:', args);

        // 在此处可以添加自定义逻辑,例如:
        // - 条件限制
        // - 修改回调函数
        // - 记录日志等

        // 调用原始的 setInterval 方法
        return null;
    };

    console.log('window.setInterval 方法已被重写。');
})();