ChatGPT Privacy Blur

Blurs the font of the sidebar when the mouse is not hovering over it. So people won't read your history.

目前为 2023-04-18 提交的版本。查看 最新版本

// ==UserScript==
// @name         ChatGPT Privacy Blur
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Blurs the font of the sidebar when the mouse is not hovering over it. So people won't read your history.
// @author       You
// @match        *://*.openai.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Add CSS to the head of the document
    const style = document.createElement('style');
    style.innerHTML = `
        .blur-effect {
            filter: blur(3px);
            transition: filter 700ms ease-in-out 300ms;
        }

        .blur-effect:hover {
            filter: none;
            transition: filter 700ms ease-in-out;
        }
    `;
    document.head.appendChild(style);

    // Function to apply the blur effect
    function applyBlur(sidebar) {
        if (sidebar) {
            sidebar.classList.add('blur-effect');
        }
    }

    // Function to remove the blur effect
    function removeBlur(sidebar) {
        if (sidebar) {
            sidebar.classList.remove('blur-effect');
        }
    }

    // Function to add event listeners to toggle the blur effect
    function addListeners(sidebar) {
        if (sidebar) {
            // Apply the blur effect by default
            applyBlur(sidebar);

            // Add event listeners to toggle the blur effect
            sidebar.addEventListener('mouseover', () => removeBlur(sidebar));
            sidebar.addEventListener('mouseout', () => applyBlur(sidebar));
        }
    }

    // Get the sidebar element
    const sidebarXPath = '/html/body/div[1]/div[2]/div[1]/div/div/nav/div';
    const sidebar = document.evaluate(sidebarXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

    // Apply listeners to the current sidebar
    addListeners(sidebar);

    // Observe changes in the DOM to handle dynamic content
    const observer = new MutationObserver((mutations) => {
        for (const mutation of mutations) {
            if (mutation.type === 'childList') {
                const newSidebar = document.evaluate(sidebarXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
                addListeners(newSidebar);
            }
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();

QingJ © 2025

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