Greasy Fork is available in English.
Prevents deletion of filtered/censored answers on DeepSeek. This is purely visual change. FILTERED ANSWERS WILL PERSIST ONLY UNTIL THE PAGE IS RELOADED.
当前为
// ==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);
};
})();