Auto collapse sidebars in Google AI Studio. 原网页总是莫名弹出左右栏,非常反人类。Trim excess margins. 去除上下左右多余空白,释放阅读空间。The script will automatically activate the grounding(google search) feature for new chats. 自动点开google搜索。Adjust fonts for better readability. 调整字体、大小、行高、线条粗细、使用像素级别抗锯齿等等(在代码末尾的css里修改)。
当前为
// ==UserScript==
// @name Chatable Google AI Studio 聊得下去的 Gemini 开发者模式
// @namespace http://tampermonkey.net/
// @version 3.1
// @description Auto collapse sidebars in Google AI Studio. 原网页总是莫名弹出左右栏,非常反人类。Trim excess margins. 去除上下左右多余空白,释放阅读空间。The script will automatically activate the grounding(google search) feature for new chats. 自动点开google搜索。Adjust fonts for better readability. 调整字体、大小、行高、线条粗细、使用像素级别抗锯齿等等(在代码末尾的css里修改)。
// @icon https://www.gstatic.com/aistudio/ai_studio_favicon_256x256.png
// @author qianjunlang
// @match https://aistudio.google.com/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
const DEBOUNCE_WAIT = 150;
const SELECTORS = {
SIDEBAR: '.layout-navbar.ng-trigger-parent.expanded',
TOGGLE_BUTTON1: 'button[aria-label="Expand or collapse navigation menu"]',
TOGGLE_BUTTON2: 'button[aria-label="Expand or collapse run settings panel"]'
};
const collapseSidebar = () => {
const expandedSidebar = document.querySelector(SELECTORS.SIDEBAR);
if ( !expandedSidebar || !window.location.href.includes('/prompts/') ) return;
expandedSidebar.querySelector(SELECTORS.TOGGLE_BUTTON1).click();
if (window.location.href.endsWith('/new_chat')){
const searchToggle = document.querySelector('.search-as-a-tool-toggle button');
if (searchToggle && !document.querySelector('.search-source')) searchToggle.click();
} else if ( document.querySelector('.footer.run-settings-expanded') )
document.querySelector(SELECTORS.TOGGLE_BUTTON2).click();
};
let debounceTimer;
const debounce = (fn, wait) => {
return function(...args) {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => fn.apply(this, args), wait);
};
};
const debouncedCollapse = debounce(collapseSidebar, DEBOUNCE_WAIT);
new MutationObserver(mutations => {
mutations.forEach(mutation => {
if (mutation.target.classList.contains('expanded')) {
debouncedCollapse();
}
});
}).observe(document.body, {
subtree: true,
attributes: true,
attributeFilter: ['class']
});
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
const style = document.createElement('style');
style.textContent = `
body > app-root select-header {
height: 50.25px;
}
body > app-root ms-prompt-switcher ms-system-instructions{
padding-top : 0 !important;
padding-left : 12px !important;
padding-right: 12px !important;
}
body > app-root ms-prompt-switcher ms-system-instructions > div{
margin : 0!important;
padding: 0!important;
}
body > app-root ms-prompt-switcher ms-system-instructions > div > textarea{
margin-left : 24px!important;
margin-right : 20px!important;
}
body > app-root ms-prompt-switcher footer{
margin-bottom : 0 !important;
padding-bottom: 0!important;
}
body > app-root ms-prompt-switcher ms-chat-session > ms-autoscroll-container{
padding-left : 28px!important;
padding-right: 28px!important;
}
body ms-cmark-node p {
font-size: 15.5px !important;
line-height: 1.6 !important;
font-family: "Roboto", "Open Sans", "Source Han Sans", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif !important;
/*font-weight: 300 !important;*/
-webkit-font-smoothing: antialiased !important;
-moz-osx-font-smoothing: grayscale !important;
text-rendering: optimizeLegibility !important;
}
body ms-cmark-node .inline-code {
font-size: 15.5px !important;
letter-spacing: 0.04em !important; /* 略微增加字间距 */
font-family: 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace !important;
}
body ms-cmark-node pre code {
font-size: 14.5px !important;
line-height: 1.1 !important;
font-family: Consolas, 'SF Mono', 'Roboto Mono', 'Cascadia Code', Menlo, monospace !important;
}
`;
document.head.appendChild(style);
})();