Greasy Fork is available in English.
自动隐藏 MiMo AI Studio 侧边栏,CSS 注入防止闪烁,一次点击同步 React 状态
// ==UserScript==
// @name MiMo AI Studio - 自动隐藏侧边栏
// @namespace https://aistudio.xiaomimimo.com/
// @version 1.0.0
// @description 自动隐藏 MiMo AI Studio 侧边栏,CSS 注入防止闪烁,一次点击同步 React 状态
// @author XforceRyan
// @match https://aistudio.xiaomimimo.com/*
// @license MIT
// @run-at document-start
// @grant none
// ==/UserScript==
(function () {
'use strict';
// ===== Phase 1: 在 React 渲染前注入 CSS,立即隐藏侧边栏 =====
// 选择器精确匹配:主 flex 容器的第一个 z-[49] 子元素(即侧边栏)
const style = document.createElement('style');
style.id = 'mimo-sidebar-auto-hide';
style.textContent = `
/* 强制侧边栏容器宽度为 0 */
.flex.flex-1.overflow-hidden > .relative.z-\\[49\\]:first-child {
width: 0 !important;
min-width: 0 !important;
overflow: hidden !important;
}
/* 内容面板滑出可视区域 */
.flex.flex-1.overflow-hidden > .relative.z-\\[49\\]:first-child > .flex {
transform: translateX(100%) !important;
}
`;
(document.head || document.documentElement).appendChild(style);
// ===== Phase 2: React 渲染后,点击按钮同步状态,然后移除 CSS 覆盖 =====
let done = false;
function syncState() {
if (done) return;
const btn = document.querySelector('[aria-label="Hide sidebar"]');
if (!btn) return;
done = true;
btn.click();
// React 现在接管了侧边栏状态,移除 CSS 覆盖
style.remove();
}
// 轮询等待 React 完成渲染
const timer = setInterval(() => {
syncState();
if (done) clearInterval(timer);
}, 300);
// 兜底:10 秒后无论如何清理
setTimeout(() => {
clearInterval(timer);
if (!done) style.remove();
}, 10000);
})();