Greasy Fork

来自缓存

Greasy Fork is available in English.

DeepSeeker

Prevents deletion of filtered/censored answers on DeepSeek. This is purely visual change. FILTERED ANSWERS WILL PERSIST ONLY UNTIL THE PAGE IS RELOADED.

当前为 2025-02-05 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         DeepSeeker
// @namespace    https://github.com/qt-kaneko/DeepSeeker
// @version      1.0.2
// @description  Prevents deletion of filtered/censored answers on DeepSeek. This is purely visual change. FILTERED ANSWERS WILL PERSIST ONLY UNTIL THE PAGE IS RELOADED.
// @author       Kaneko Qt
// @license      GPL-3.0-or-later
// @match        https://chat.deepseek.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=deepseek.com
// @run-at       document-start
// @unwrap
// @noframes
// ==/UserScript==

(function() { "use strict";

const _endpoints = [
  `https://chat.deepseek.com/api/v0/chat/edit_message`,
  `https://chat.deepseek.com/api/v0/chat/completion`,
  `https://chat.deepseek.com/api/v0/chat/regenerate`
];

const _addEventListener = XMLHttpRequest.prototype.addEventListener;
const _responseText = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, `responseText`);

/**
 * @this {XMLHttpRequest}
 * @template {keyof XMLHttpRequestEventMap} K
 * @param {K} type
 * @param {(this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any} listener
 * @param {boolean | AddEventListenerOptions | undefined} options
 */
XMLHttpRequest.prototype.addEventListener = function(type, listener, options, ...rest) {
  if (type === `readystatechange`)
  {
    let originalListener = listener;

    listener = function(ev, ...rest) {
      if ((this.readyState === 3 || this.readyState === 4) && _endpoints.includes(this.responseURL))
      {
        let eventsText = _responseText.get.call(this);
        let events = eventsText.split(`\n\n`);

        for (let [eventI, event] of events.entries())
        {
          if (event === ``) continue;
          if (event === `data: [DONE]`) continue;

          let eventJson = JSON.parse(event.slice(`data: `.length));
          if (eventJson.choices?.[0]?.finish_reason === `content_filter`)
          {
            console.log(`[DeepSeeker] Get patched, idiot :P`);

            eventJson.choices[0].finish_reason = `stop`;
            events[eventI] = `data: ` + JSON.stringify(eventJson);
          }
        }

        eventsText = events.join(`\n\n`);
        Object.defineProperty(this, `response`, {value: eventsText, configurable: true});
        Object.defineProperty(this, `responseText`, {value: eventsText, configurable: true});
      }

      return originalListener.call(this, ev, ...rest);
    };
  }

  return _addEventListener.call(this, type, listener, options, ...rest);
};

})();