🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

DeepSeek大屏优化

优化DeepSeek页面样式

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         DeepSeek大屏优化
// @namespace    http://tampermonkey.net/
// @version      2.4.3
// @description  优化DeepSeek页面样式
// @author       HuSheng
// @match        https://chat.deepseek.com/**
// @exclude      https://chat.deepseek.com/sign_in
// @exclude      https://chat.deepseek.com/sign_up
// @exclude      https://chat.deepseek.com/forgot_password
// @icon         https://chat.deepseek.com/favicon.svg
// @grant        none
// @run-at       document-body
// @license       GPL-2.0-only
// ==/UserScript==

(function () {
    'use strict';

    // xpath
    const xpaths_css = [
        {key: '/html/body/div[1]/div/div/div[2]/div[1]/div/div[2]', value: 'display: none', sleep: 0},

        {key: '/html/body/div[1]/div/div/div[2]/div[3]/div/div/div[2]', value: 'width: 100%; max-width: 100%', sleep: 0},
        {key: '/html/body/div[1]/div/div/div[2]/div[3]/div/div[2]/div/div[2]', value: 'padding: 0', sleep: 0},
        {key: '/html/body/div[1]/div/div/div[2]/div[3]/div/div/div[2]/div[2]', value: 'width: 90%; max-width: 1200px', sleep: 0},

        {key: '/html/body/div[1]/div/div/div[2]/div[3]/div/div[2]/div/div[2]/div[2]/div[2]/div/div/div[1]', value: '--line-height: none;', sleep: 0},
        {key: '/html/body/div[1]/div/div/div[2]/div[3]/div/div[2]/div/div/div[3]/div[1]', value: 'width: 100%; max-width: 100%;', sleep: 0},
        {key: '/html/body/div[1]/div/div/div[2]/div[3]/div/div[2]/div/div[2]/div[2]/div[3]', value: 'display: none', sleep: 0},
        {key: '/html/body/div[1]/div/div/div[2]/div[3]/div/div[2]/div/div[2]/div[2]/div[2]', value: 'margin-bottom: 10px;', sleep: 0},

    ];

    // CSS
    const css_css = [
    ];


    function delay(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    function applyCSSStyles(element, cssText) {
        const styles = cssText.split(';').filter(style => style.trim() !== '');

        styles.forEach(style => {
            const [property, value] = style.split(':').map(s => s.trim());
            if (property && value) {
                // 处理CSS自定义属性
                if (property.startsWith('--')) {
                    element.style.setProperty(property, value);
                } else {
                    // 转换CSS属性名到JS格式(如background-color -> backgroundColor)
                    const jsProperty = property.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
                    element.style[jsProperty] = value;
                }
            }
        });
    }

    // 修改元素样式
    async function modifyElementStyles() {
        // xpath方式
        for (const xpath of xpaths_css) {
            if (xpath.sleep > 0) {
                await delay(xpath.sleep);
            }

            try {
                const element = document.evaluate(
                    xpath.key,
                    document,
                    null,
                    XPathResult.FIRST_ORDERED_NODE_TYPE,
                    null
                ).singleNodeValue;

                if (element) {
                    applyCSSStyles(element, xpath.value);
                } else if (xpath.key) {
                    console.error(`未找到XPath目标元素:${xpath.key}`);
                }
            } catch (e) {
                console.error(`XPath查询错误:${xpath.key}`, e);
            }
        }

        // CSS方式
        for (const css of css_css) {
            if (css.sleep > 0) {
                await delay(css.sleep);
            }

            try {
                const elements = document.querySelectorAll(css.key);
                if (elements.length > 0) {
                    elements.forEach(element => {
                        applyCSSStyles(element, css.value);
                    });
                } else if (css.key) {
                    console.error(`未找到CSS目标元素:${css.key}`);
                }
            } catch (e) {
                console.error(`CSS查询错误:${css.key}`, e);
            }
        }
    }

    // 监听URL变化
    function observeUrlChanges() {
        let lastUrl = location.href;

        const urlChangeHandler = function() {
            if (location.href !== lastUrl) {
                lastUrl = location.href;
                modifyElementStyles();
            }
        };

        window.addEventListener('popstate', urlChangeHandler);
        window.addEventListener('hashchange', urlChangeHandler);

        const originalPushState = history.pushState;
        const originalReplaceState = history.replaceState;

        history.pushState = function() {
            originalPushState.apply(this, arguments);
            urlChangeHandler();
        };

        history.replaceState = function() {
            originalReplaceState.apply(this, arguments);
            urlChangeHandler();
        };
    }

    // 页面加载时执行
    function init() {
        modifyElementStyles();
        observeUrlChanges();

        const observer = new MutationObserver(function(mutations) {
            const shouldUpdate = mutations.some(mutation => {
                return true;
            });

            if (shouldUpdate) {
                modifyElementStyles();
            }
        });

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

    if (document.readyState === 'complete' || document.readyState === 'interactive') {
        setTimeout(init, 0);
    } else {
        document.addEventListener('DOMContentLoaded', init);
        window.addEventListener('load', init);
    }
})();