温馨遗言

文心一言去水印,支持自定义|失效不一定修

Version vom 15.04.2023. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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 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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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         温馨遗言
// @namespace    wenxinyiyan.taozhiyu.gitee.io
// @version      0.1
// @description  文心一言去水印,支持自定义|失效不一定修
// @author       涛之雨
// @match        https://yiyan.baidu.com/
// @icon         https://nlp-eb.cdn.bcebos.com/logo/favicon.ico
// @require      https://greatest.deepsurf.us/scripts/455943-ajaxhooker/code/ajaxHooker.js?version=1124435
// @grant        GM_getValue
// @grant        GM_setValue
// @run-at       document-start
// @license      WTFPL
// ==/UserScript==

/* global ajaxHooker*/
(function() {
    'use strict';
    const wm=GM_getValue("watermark"," ");
    const rid="apply"+Math.random().toString(36).slice(2);
    Function[rid]=Function.apply;
    Function.apply=function($this,args){
        return Function[rid]($this,args.map(a=>a.replace(/debugger/ig,"")));
    };
    ajaxHooker.hook(request => {
        if (request.url.endsWith('user/info')){
            request.response = res => {
                res.json.content.watermark=wm;
            };
        }else if(request.url.endsWith('chat/query') || request.url.endsWith('chat/history')){
            request.response = res => {
                res.json=JSON.parse(JSON.stringify(res.json).replace(/x-bce-process/g,"?&"));
            };
        }
    });
    const id=setInterval(()=>{
        if(!document.querySelector('.ant-menu-submenu-title img'))return;
        clearInterval(id);
        document.querySelector('.ant-menu-submenu-title img').ondblclick=function(){
            const inp=prompt("请输入自定义水印内容:",""+wm.slice(1));
            if(inp===null)return;
            GM_setValue("watermark",` ${inp}`);
            confirm("设置成功,刷新后生效。\n是否立即刷新?")&&location.reload();
        };
    },200);
})();