Skip to content

Instantly share code, notes, and snippets.

@drandarov-io
Last active May 11, 2025 18:31
Show Gist options
  • Select an option

  • Save drandarov-io/1d489ee37d8d24f7e28c0cd793bdd9f4 to your computer and use it in GitHub Desktop.

Select an option

Save drandarov-io/1d489ee37d8d24f7e28c0cd793bdd9f4 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Notion Compact Text and Sidebar
// @namespace http://tampermonkey.net/
// @version 1.4
// @description Adjust layout to waste less space with page icons and covers and reduce vertical spacing between blocks
// @author Dmitrij Drandarov
// @match https://www.notion.so/*
// @grant none
// @url https://gist.github.com/drandarov-io/1d489ee37d8d24f7e28c0cd793bdd9f4
// ==/UserScript==
(() => {
'use strict';
const injectCSS = () => {
const style = document.createElement('style');
style.innerHTML = `
.layout-content { padding-top: 0px !important; margin-top: -2px !important; }
.layout-full div[style*="max-height"] { max-height: 130px !important; }
.layout:not(:has(svg.addPageCover)):has(svg.addPage) .layout-full div:has(> img)[style*="grid-area"] { margin-top: -40px !important; }
.layout-full div:has(> img)[style*="grid-area"] { margin-top: -75px !important; }
.layout-content:has(svg.addPageCover) div[role="button"].notion-record-icon[style*="width: 78px"] { margin-top: 30px !important; }
.layout-content:has(svg.addPageCover) div[role="button"].notion-record-icon[style*="width: 140px"] { margin-top: 0px !important; }
.layout-content:not(:has(svg.addPageCover)) div[role="button"].notion-record-icon[style*="width: 78px"] { margin-top: -25px !important; }
.layout-content:not(:has(svg.addPageCover)) div[role="button"].notion-record-icon[style*="width: 140px"] { margin-top: -90px !important; }
.notion-bulleted_list-block { margin-bottom: 1px !important; margin-top: -3px !important; }
.notion-header-block { margin-top: 0.6em !important; }
.notion-sub_header-block { margin-top: 0.4em !important; margin-bottom: 0.5em !important; }
.notion-sub_sub_header-block { margin-top: 0.25em !important; margin-bottom: 0.2em !important; }
.notion-selectable-hover-menu-item .notion-selectable-drag-handle { margin-bottom: 0px !important; margin-top: 2px !important; }
.notion-selectable-hover-menu-item div[role*="button"] { margin-bottom: 0px !important; margin-top: 2px !important; }
.line-numbers.notion-code-block { padding: 4px 0px 12px 0px !important; }
div:has(> .line-numbers.notion-code-block) { padding: 20px 8px 0px 16px !important; }
.notion-sidebar > div > div > div > a > div { min-height: 25px !important; height: 25px !important; }
div[role="tree"] > div > div > div > a > div { margin-bottom: -2px !important; margin-top: -2px !important; }
div[role="tree"] div[role="group"] > div > div > div > a > div { padding: 0px 8px 0px 25px !important; margin-bottom: -3px !important; margin-top: -3px !important; }
div[role="tree"] div[role="group"] div[role="group"] > div > div > div > a > div { padding: 0px 8px 0px 35px !important; margin-bottom: -3px !important; margin-top: -3px !important; }
div[role="tree"] div[role="group"] div[role="group"] div[role="group"] > div > div > div > a > div { padding: 0px 8px 0px 45px !important; margin-bottom: -3px !important; margin-top: -3px !important; }
`;
document.head.appendChild(style);
};
injectCSS();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment