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 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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 });
})();