Greasy Fork

Greasy Fork is available in English.

深度搜索特性

复制OpenAI的ChatGPT特性功能,默认无操作,需通过用户脚本配置

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         DeepSeek Traits
// @name:zh-CN   深度搜索特性
// @namespace    http://tampermonkey.net/
// @version      2025-01-24
// @description  A recreation of OpenAI's ChatGPT Traits feature. By default does nothing. Configure via userscript.
// @description:zh-CN 复制OpenAI的ChatGPT特性功能,默认无操作,需通过用户脚本配置
// @author       https://github.com/xskutsu
// @match        *://*.deepseek.com/*
// @grant        GM_registerMenuCommand
// @grant        GM_getValue
// @grant        GM_setValue
// @icon         https://www.google.com/s2/favicons?sz=64&domain=deepseek.com
// @license      MIT
// ==/UserScript==

(function () {
    "use strict";
    const locale = {
        en: {
            set: "Set DeepSeek Traits",
            clear: "Clear DeepSeek Traits",
            prompt: "Enter traits for DeepSeek:",
            updated: "Traits Updated!",
            confirm: "Are you sure you want to clear DeepSeek Traits?",
            cleared: "Traits cleared!",
            instruct: "When you respond to this message by the user, please follow these DeepSeek Traits (instructions, guidelines, desires) provided by the user: "
        },
        zh: {
            set: "设置DeepSeek特性",
            clear: "清除DeepSeek特性",
            prompt: "输入DeepSeek的特性:",
            updated: "特性已更新!",
            confirm: "确定要清除DeepSeek特性吗?",
            cleared: "特性已清除!",
            instruct: "当您回复用户的此消息时,请遵循用户提供的这些DeepSeek特质(指示、指南、需求):"
        }
    };
    const t = locale[navigator.language.startsWith('zh') ? 'zh' : 'en'];

    let DeepSeekTraits = GM_getValue("traits", "");

    GM_registerMenuCommand(t.set, function () {
        const traits = prompt(t.prompt, GM_getValue("traits", "")).trim().replace(/[\n\r\t]/gm, "");
        if (traits.length !== 0) {
            GM_setValue("traits", traits);
            DeepSeekTraits = traits;
            alert(t.updated);
        }
    });

    GM_registerMenuCommand(t.clear, function () {
        if (confirm(t.confirm)) {
            GM_setValue("traits", "");
            DeepSeekTraits = "";
            alert(t.cleared);
        }
    });

    function isJson(str) {
        try {
            JSON.parse(str);
        } catch (e) {
            return false;
        }
        return true;
    }

    const originalSend = XMLHttpRequest.prototype.send;
    XMLHttpRequest.prototype.send = function(body, ...args) {
        if (isJson(body) && DeepSeekTraits.length !== 0) {
            const data = JSON.parse(body);
            if (data.hasOwnProperty("prompt")) {
                data.prompt = `${t.instruct}"${DeepSeekTraits}"\n\nUser:\n${data.prompt}`;
                body = JSON.stringify(data);
            }
        }
        originalSend.call(this, body, ...args);
    };
})();