You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Confluence搜索页面通过客户端方式阻止AI生成答案框(含请求拦截)

如何在Confluence搜索页面通过客户端方式阻止AI生成答案框(含请求拦截)

我完全懂你不想被这个AI生成的Overview框打扰,还不想浪费资源去加载它的请求——毕竟uMatrix直接拦整个端点不太现实,得搞精准拦截。下面给你几个实用的客户端方案:

方法一:用Tampermonkey脚本精准拦截请求

浏览器油猴脚本可以帮你针对性阻断触发AI答案的请求,不会影响其他正常的API调用。你可以这么做:

  1. 安装Tampermonkey(或者其他类似的用户脚本管理器)
  2. 新建一个脚本,粘贴下面的代码:
// ==UserScript==
// @name         Block Confluence AI Search Answer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Block the AI-generated Overview box in Confluence search
// @author       You
// @match        https://your-confluence-domain.com/*search*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 拦截fetch请求
    const originalFetch = window.fetch;
    window.fetch = async function(resource, options) {
        // 检查请求URL是否是目标API
        if (resource.includes('/gateway/api/gasv3/api/v1/batch')) {
            // 检查请求体里的actionSubject是否包含AI答案相关标识
            if (options?.body) {
                try {
                    const body = JSON.parse(options.body);
                    const hasAIAnswer = body.some(item => 
                        item.actionSubject?.includes('aiAnswerExp')
                    );
                    if (hasAIAnswer) {
                        console.log('Blocking Confluence AI answer request');
                        // 阻断请求,返回空响应
                        return new Response(JSON.stringify([]), {status: 200});
                    }
                } catch(e) {
                    // 解析失败就放行
                }
            }
        }
        return originalFetch.apply(this, arguments);
    };

    // 同时拦截XMLHttpRequest(以防Confluence用这个发送请求)
    const originalXHR = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url) {
        this._url = url;
        originalXHR.apply(this, arguments);
    };

    const originalSend = XMLHttpRequest.prototype.send;
    XMLHttpRequest.prototype.send = function(body) {
        if (this._url.includes('/gateway/api/gasv3/api/v1/batch') && body) {
            try {
                const parsedBody = JSON.parse(body);
                const hasAIAnswer = parsedBody.some(item => 
                    item.actionSubject?.includes('aiAnswerExp')
                );
                if (hasAIAnswer) {
                    console.log('Blocking Confluence AI answer XHR request');
                    // 中止请求
                    this.abort();
                    return;
                }
            } catch(e) {}
        }
        originalSend.apply(this, arguments);
    };
})();
  1. 把脚本里的https://your-confluence-domain.com/*search*替换成你公司的Confluence域名,保存启用就行。

这个脚本会检查所有发往目标API的请求,只要请求体里包含AI答案相关的标识,就直接阻断或者返回空响应,不会影响其他正常的搜索请求。

方法二:结合CSS隐藏+脚本阻止DOM渲染

如果上面的请求拦截偶尔有漏网之鱼,再加上这一步双重保险:

  1. 同样用Tampermonkey,或者用浏览器的自定义CSS工具(比如Chrome的“自定义样式表”),添加下面的CSS:
#ai-answer-result-section {
    display: none !important;
}
  1. 再配合一段脚本阻止这个DOM元素的初始化:
// 在油猴脚本里追加这段代码
(function() {
    'use strict';
    // 监听DOM变化,一旦AI答案框出现就移除它
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            const aiBox = document.getElementById('ai-answer-result-section');
            if (aiBox) {
                aiBox.remove();
                observer.disconnect(); // 找到后就停止监听
            }
        });
    });

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

这样就算请求没被完全拦截,也会直接把这个框从页面上删掉,不会显示出来。

额外小提示

  • 测试的时候可以打开浏览器的开发者工具(F12),看Network标签里的请求,如果那个AI相关的请求被拦截了,会在控制台看到我们脚本里的日志提示。
  • 如果Confluence更新了API或者元素ID,你可能需要稍微调整脚本里的标识,比如actionSubject的关键词或者DOM元素ID。

备注:内容来源于stack exchange,提问作者Nemo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 12:18:08