{"slug": "gemini-adaptive-tables-clean-ui-scroll-lock-violentmonkey-userscript", "title": "Gemini Adaptive Tables, Clean UI & Scroll-Lock (Violentmonkey userscript)", "summary": "A developer known as leitonico released a Violentmonkey userscript that fixes Gemini's chat interface, making wide tables adapt symmetrically without layout shift, repairing broken inline-code auto-links, and blocking autoscroll during generation. The script runs with @grant none at document-start and targets gemini.google.com, applying CSS overrides to conversation containers and table blocks.", "body_md": "|  | // ==UserScript== | \n|  | // @name Gemini Adaptive Tables, Clean UI & Scroll-Lock | \n|  | // @name:pt-BR Gemini: Tabelas Adaptáveis, UI Limpa e Trava de Rolagem | \n|  | // @namespace leitonico3000 | \n|  | // @version 1.1 | \n|  | // @author leitonico | \n|  | // @description Native chat & prompt bar, symmetric adaptive wide tables with no layout shift, fixes broken inline-code auto-links, blocks autoscroll while generating. Non-intrusive: @grant none. | \n|  | // @description:pt-BR Chat e barra de prompt nativos, tabelas largas adaptáveis e simétricas sem pulos de layout, corrige auto-links quebrados em código inline, bloqueia autoscroll na geração. Não intrusivo: @grant none. | \n|  | // @homepageURL https://gist.github.com/leitonico/ce43f464613e47041f662a5f69efc623 | \n|  | // @updateURL https://gist.githubusercontent.com/leitonico/ce43f464613e47041f662a5f69efc623/raw/gemini-adaptive-tables.user.js | \n|  | // @downloadURL https://gist.githubusercontent.com/leitonico/ce43f464613e47041f662a5f69efc623/raw/gemini-adaptive-tables.user.js | \n|  | // @match https://gemini.google.com/* | \n|  | // @grant none | \n|  | // @run-at document-start | \n|  | // ==/UserScript== | \n|  | (function () { | \n|  | 'use strict'; | \n|  | const STYLE_ID = 'gemini-adaptive-tables-css'; | \n|  | const SPECIFICITY = ':not(#_):not(#_):not(#_)'; | \n|  | const SAFE_WIDTH_VAR = '--gemini-max-safe-w'; | \n|  | const TABLE_WIDTH_VAR = '--gemini-wide-table-w'; | \n|  | const TABLE_SELECTOR = 'table-block, .table-block'; | \n|  | const INLINE_CODE_SELECTOR = '.markdown code, .model-response-text code, message-content code'; | \n|  | const CODE_BLOCK_SELECTOR = 'pre, code-block, .code-block'; | \n|  | const AUTO_LINK_RE = /\\[([^\\]]+)\\]$(https?:\\/\\/[^)\\s]+)$/g; | \n|  | const HOOK_MARK = Symbol.for('gemini-scroll-lock'); | \n|  | function rule(selectors, declarations) { | \n|  | return `${selectors.map((selector) => selector + SPECIFICITY).join(',\\n')} {${declarations}}`; | \n|  | } | \n|  | const CSS = [ | \n|  | rule([ | \n|  | '.conversation-container', | \n|  | 'response-container', | \n|  | '.response-container', | \n|  | '.response-container-content', | \n|  | '.response-content', | \n|  | 'model-response', | \n|  | '.model-response-text', | \n|  | 'message-content', | \n|  | '.markdown', | \n|  | '.markdown-main-panel', | \n|  | 'structured-content-container' | \n|  | ], ` | \n|  | overflow-x: visible !important; | \n|  | `), | \n|  | rule(['.markdown', '.model-response-text'], ` | \n|  | font-size: 14.5px !important; | \n|  | line-height: 1.52 !important; | \n|  | `), | \n|  | rule(['table-block', '.table-block'], ` | \n|  | display: block !important; | \n|  | margin: 14px 0 !important; | \n|  | background: rgba(255, 255, 255, 0.025) !important; | \n|  | border: 1px solid rgba(255, 255, 255, 0.11) !important; | \n|  | border-radius: 12px !important; | \n|  | box-sizing: border-box !important; | \n|  | overflow: hidden !important; | \n|  | `), | \n|  | rule([ | \n|  | 'table-block > div', | \n|  | 'table-block .table-content', | \n|  | 'table-block .horizontal-scroll-wrapper', | \n|  | '.table-block > div', | \n|  | '.table-content', | \n|  | '.horizontal-scroll-wrapper' | \n|  | ], ` | \n|  | width: 100% !important; | \n|  | max-width: 100% !important; | \n|  | min-width: 0 !important; | \n|  | margin-left: 0 !important; | \n|  | margin-right: 0 !important; | \n|  | padding-left: 0 !important; | \n|  | padding-right: 0 !important; | \n|  | left: auto !important; | \n|  | transform: none !important; | \n|  | box-sizing: border-box !important; | \n|  | overflow-x: auto !important; | \n|  | `), | \n|  | rule(['table-block[data-table-size=\"small\"]', '.table-block[data-table-size=\"small\"]'], ` | \n|  | position: static !important; | \n|  | left: auto !important; | \n|  | transform: none !important; | \n|  | width: 100% !important; | \n|  | max-width: 100% !important; | \n|  | `), | \n|  | rule(['table-block[data-table-size=\"wide\"]', '.table-block[data-table-size=\"wide\"]'], ` | \n|  | position: relative !important; | \n|  | left: 50% !important; | \n|  | transform: translateX(-50%) !important; | \n|  | width: var(${TABLE_WIDTH_VAR}, 88vw) !important; | \n|  | max-width: var(${SAFE_WIDTH_VAR}, 92vw) !important; | \n|  | `), | \n|  | rule(['table-block table', '.markdown table'], ` | \n|  | width: 100% !important; | \n|  | max-width: 100% !important; | \n|  | min-width: 0 !important; | \n|  | margin: 0 !important; | \n|  | border-collapse: collapse !important; | \n|  | border-spacing: 0 !important; | \n|  | display: table !important; | \n|  | table-layout: auto !important; | \n|  | font-size: 13.5px !important; | \n|  | line-height: 1.38 !important; | \n|  | `), | \n|  | rule(['table-block[data-table-size=\"wide\"] table'], ` | \n|  | font-size: 12.5px !important; | \n|  | line-height: 1.35 !important; | \n|  | `), | \n|  | rule(['table-block thead tr', '.markdown thead tr'], ` | \n|  | background: rgba(255, 255, 255, 0.055) !important; | \n|  | border-bottom: 1px solid rgba(255, 255, 255, 0.16) !important; | \n|  | `), | \n|  | rule(['table-block tbody tr', '.markdown tbody tr'], ` | \n|  | border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important; | \n|  | transition: background-color 0.12s ease !important; | \n|  | `), | \n|  | rule(['table-block tbody tr:last-child', '.markdown tbody tr:last-child'], ` | \n|  | border-bottom: none !important; | \n|  | `), | \n|  | rule(['table-block tbody tr:hover', '.markdown tbody tr:hover'], ` | \n|  | background: rgba(255, 255, 255, 0.04) !important; | \n|  | `), | \n|  | rule(['table-block th', '.markdown th'], ` | \n|  | padding: 8px 11px !important; | \n|  | font-weight: 600 !important; | \n|  | text-align: left !important; | \n|  | vertical-align: bottom !important; | \n|  | border: none !important; | \n|  | min-width: 0 !important; | \n|  | white-space: normal !important; | \n|  | word-break: normal !important; | \n|  | overflow-wrap: break-word !important; | \n|  | `), | \n|  | rule(['table-block td', '.markdown td'], ` | \n|  | padding: 7px 11px !important; | \n|  | text-align: left !important; | \n|  | vertical-align: top !important; | \n|  | border: none !important; | \n|  | min-width: 0 !important; | \n|  | white-space: normal !important; | \n|  | word-break: normal !important; | \n|  | overflow-wrap: break-word !important; | \n|  | `), | \n|  | rule(['table-block[data-table-size=\"wide\"] th'], ` | \n|  | padding: 7px 8px !important; | \n|  | `), | \n|  | rule(['table-block[data-table-size=\"wide\"] td'], ` | \n|  | padding: 6px 8px !important; | \n|  | `), | \n|  | rule(['table-block td *', '.markdown td *', 'source-footnote', '.citation-chip'], ` | \n|  | white-space: normal !important; | \n|  | word-break: normal !important; | \n|  | overflow-wrap: break-word !important; | \n|  | max-width: 100% !important; | \n|  | `), | \n|  | rule(['.table-footer'], ` | \n|  | padding: 5px 12px !important; | \n|  | border-top: 1px solid rgba(255, 255, 255, 0.08) !important; | \n|  | background: rgba(255, 255, 255, 0.015) !important; | \n|  | `) | \n|  | ].join('\\n\\n'); | \n|  | function injectCSS() { | \n|  | if (document.getElementById(STYLE_ID)) return; | \n|  | const style = document.createElement('style'); | \n|  | style.id = STYLE_ID; | \n|  | style.textContent = CSS; | \n|  | (document.head \\|\\| document.documentElement).appendChild(style); | \n|  | } | \n|  | injectCSS(); | \n|  | function setStyleProperty(element, name, value) { | \n|  | if (element.style.getPropertyValue(name) !== value) { | \n|  | element.style.setProperty(name, value); | \n|  | } | \n|  | } | \n|  | function classifyAndSizeTables() { | \n|  | const blocks = document.querySelectorAll(TABLE_SELECTOR); | \n|  | if (blocks.length === 0) return; | \n|  | const scroller = document.querySelector('infinite-scroller') \\|\\| document.querySelector('main'); | \n|  | const safeMaxW = scroller && scroller.clientWidth > 320 | \n|  | ? Math.max(680, scroller.clientWidth - 40) | \n|  | : Math.floor(window.innerWidth * 0.92); | \n|  | setStyleProperty(document.documentElement, SAFE_WIDTH_VAR, `${safeMaxW}px`); | \n|  | blocks.forEach((block) => { | \n|  | const firstRow = block.querySelector('tr'); | \n|  | if (!firstRow) return; | \n|  | const colCount = firstRow.querySelectorAll('th, td').length; | \n|  | if (colCount <= 4) { | \n|  | if (block.dataset.tableSize !== 'small') { | \n|  | block.dataset.tableSize = 'small'; | \n|  | } | \n|  | } else { | \n|  | if (block.dataset.tableSize !== 'wide') { | \n|  | block.dataset.tableSize = 'wide'; | \n|  | } | \n|  | const idealW = Math.min(safeMaxW, Math.max(860, colCount * 128)); | \n|  | setStyleProperty(block, TABLE_WIDTH_VAR, `${idealW}px`); | \n|  | } | \n|  | }); | \n|  | } | \n|  | function stripRedundantAutoLink(full, label, url) { | \n|  | const withoutProto = url.replace(/^https?:\\/\\//i, ''); | \n|  | if (url === label \\|\\| withoutProto === label \\|\\| withoutProto === `${label}/`) { | \n|  | return label; | \n|  | } | \n|  | return full; | \n|  | } | \n|  | function cleanBrokenInlineCodeLinks() { | \n|  | const codes = document.querySelectorAll(INLINE_CODE_SELECTOR); | \n|  | for (let i = 0; i < codes.length; i++) { | \n|  | const code = codes[i]; | \n|  | if (code.childElementCount > 0 \\|\\| code.closest(CODE_BLOCK_SELECTOR)) continue; | \n|  | const raw = code.textContent; | \n|  | if (!raw \\|\\| !raw.includes('](')) continue; | \n|  | const cleaned = raw.replace(AUTO_LINK_RE, stripRedundantAutoLink); | \n|  | if (cleaned !== raw) { | \n|  | code.textContent = cleaned; | \n|  | } | \n|  | } | \n|  | } | \n|  | let frameId = 0; | \n|  | function processDOM() { | \n|  | frameId = 0; | \n|  | injectCSS(); | \n|  | classifyAndSizeTables(); | \n|  | cleanBrokenInlineCodeLinks(); | \n|  | } | \n|  | function scheduleProcessing() { | \n|  | if (!frameId) frameId = requestAnimationFrame(processDOM); | \n|  | } | \n|  | window.addEventListener('resize', scheduleProcessing, { passive: true }); | \n|  | const observer = new MutationObserver(scheduleProcessing); | \n|  | observer.observe(document.documentElement, { childList: true, subtree: true }); | \n|  | let scrollCallCount = 0; | \n|  | let scrollUrl = location.href; | \n|  | function hookScroll(target, name) { | \n|  | const original = target[name]; | \n|  | if (!original) return false; | \n|  | if (original[HOOK_MARK]) return true; | \n|  | const wrapped = function (...args) { | \n|  | if (location.href !== scrollUrl) { | \n|  | scrollUrl = location.href; | \n|  | scrollCallCount = 0; | \n|  | } | \n|  | if (++scrollCallCount === 1) return original.apply(this, args); | \n|  | }; | \n|  | Object.defineProperty(wrapped, HOOK_MARK, { value: true }); | \n|  | try { | \n|  | Object.defineProperty(target, name, { value: wrapped, writable: false, configurable: false }); | \n|  | return true; | \n|  | } catch { | \n|  | return false; | \n|  | } | \n|  | } | \n|  | function applyScrollLocks() { | \n|  | const results = [ | \n|  | hookScroll(Element.prototype, 'scrollIntoView'), | \n|  | hookScroll(Element.prototype, 'scrollTo'), | \n|  | hookScroll(Element.prototype, 'scrollBy'), | \n|  | hookScroll(Element.prototype, 'scroll'), | \n|  | hookScroll(window, 'scrollTo'), | \n|  | hookScroll(window, 'scrollBy'), | \n|  | hookScroll(window, 'scroll') | \n|  | ]; | \n|  | return results.every(Boolean); | \n|  | } | \n|  | if (!applyScrollLocks()) { | \n|  | const retryTimer = setInterval(() => { | \n|  | if (applyScrollLocks()) clearInterval(retryTimer); | \n|  | }, 1000); | \n|  | } | \n|  | })(); |", "url": "https://wpnews.pro/news/gemini-adaptive-tables-clean-ui-scroll-lock-violentmonkey-userscript", "canonical_source": "https://gist.github.com/leitonico/ce43f464613e47041f662a5f69efc623", "published_at": "2026-11-19 13:25:09+00:00", "updated_at": "2026-11-19 13:42:03.903846+00:00", "lang": "en", "topics": ["ai-products", "developer-tools"], "entities": ["Google", "Gemini", "Violentmonkey", "leitonico"], "also_reported_by": [], "takeaway": "A @grant none userscript can override Gemini's table-block and conversation-container CSS at document-start to stop layout shift and autoscroll during generation.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/gemini-adaptive-tables-clean-ui-scroll-lock-violentmonkey-userscript", "markdown": "https://wpnews.pro/news/gemini-adaptive-tables-clean-ui-scroll-lock-violentmonkey-userscript.md", "text": "https://wpnews.pro/news/gemini-adaptive-tables-clean-ui-scroll-lock-violentmonkey-userscript.txt", "jsonld": "https://wpnews.pro/news/gemini-adaptive-tables-clean-ui-scroll-lock-violentmonkey-userscript.jsonld"}}