Greasy Fork is available in English.

NotebookLM Fullscreen

Make NotebookLM dialog fullscreen with proper content scaling

// ==UserScript==
// @name         NotebookLM Fullscreen
// @namespace    http://tampermonkey.net/
// @version      0.8
// @description  Make NotebookLM dialog fullscreen with proper content scaling
// @author       You
// @match        https://notebooklm.google.com/*
// @grant        GM_addStyle
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const debug = {
        log: (...args) => console.log('[NotebookLM Debug]', ...args)
    };

    // 监听 DOM 变化
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            const dialog = document.querySelector('.mat-mdc-dialog-container');
            const container = document.querySelector('.cdk-overlay-container');

            if(container) {
                // 只对笔记编辑器对话框应用全屏效果
                if(dialog && dialog.querySelector('.note-editor')) {
                    container.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
                } else {
                    container.style.backgroundColor = 'transparent';
                }
            }
        });
    });

    // 启动观察器
    if (document.body) {
        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    } else {
        document.addEventListener('DOMContentLoaded', () => {
            observer.observe(document.body, {
                childList: true,
                subtree: true
            });
        });
    }

    // 注入样式
    GM_addStyle(`
        /* 弹出框容器 */
        .cdk-overlay-container {
            width: 100vw !important;
            height: 100vh !important;
            position: fixed !important;
            top: 0 !important;
            left: 0 !important;
            z-index: 9999 !important;
            display: flex !important;
            justify-content: center !important;
            align-items: center !important;
        }

        /* 弹出框包装器 */
        .cdk-global-overlay-wrapper {
            width: 100vw !important;
            height: 100vh !important;
            position: fixed !important;
            top: 0 !important;
            left: 0 !important;
            margin: 0 !important;
            padding: 0 !important;
        }

        /* 笔记编辑器对话框样式 */
        .note-editor .mat-mdc-dialog-container,
        .note-editor .mat-mdc-dialog-content,
        .note-editor {
            width: 100vw !important;
            height: 100vh !important;
            max-width: none !important;
            max-height: none !important;
            margin: 0 !important;
            padding: 0 !important;
            position: fixed !important;
            top: 0 !important;
            left: 0 !important;
            transform: none !important;
            box-sizing: border-box !important;
        }

        /* 编辑器内容 */
        .ql-editor,
        .prosemirror-editor {
            height: calc(100vh - 64px) !important;
            width: 100% !important;
            padding: 20px 40px !important;
            box-sizing: border-box !important;
            overflow-y: auto !important;
        }

        /* 移除所有遮罩 */
        .cdk-overlay-backdrop,
        .cdk-overlay-dark-backdrop,
        .cdk-overlay-backdrop-showing,
        .cdk-overlay-connected-position-bounding-box {
            display: none !important;
            opacity: 0 !important;
            visibility: hidden !important;
            pointer-events: none !important;
        }

        /* 修复主内容区域 */
        .main-contents {
            pointer-events: auto !important;
            background: transparent !important;
        }

        /* 修复按钮样式 */
        .note-header__controls {
            position: fixed !important;
            top: 12px !important;
            right: 12px !important;
            z-index: 10000 !important;
            display: flex !important;
            gap: 8px !important;
        }

        .note-editor-close-button {
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            width: 40px !important;
            height: 40px !important;
            border-radius: 50% !important;
            background: rgba(255, 255, 255, 0.1) !important;
            border: none !important;
            cursor: pointer !important;
            color: var(--v2-on-surface-emphasis) !important;
            z-index: 10001 !important;
        }

        .note-editor-close-button:hover {
            background: rgba(255, 255, 255, 0.2) !important;
        }

        /* 确保按钮可点击 */
        .mat-mdc-button-touch-target {
            pointer-events: none !important;
        }

        .mat-icon {
            pointer-events: auto !important;
            cursor: pointer !important;
        }

        /* 移除所有过渡动画 */
        .cdk-overlay-container *,
        .mat-mdc-dialog-container *,
        .cdk-global-overlay-wrapper *,
        .cdk-overlay-pane * {
            transition: none !important;
            animation: none !important;
        }

        /* 修复分享对话框样式 */
        .sharing-dialog {
            position: relative !important;
            width: 500px !important;
            max-width: 90vw !important;
            height: auto !important;
            background: var(--v2-surface) !important;
            border-radius: 28px !important;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.14) !important;
            z-index: 10000 !important;
        }

        .sharing-dialog .mat-mdc-dialog-container {
            position: static !important;
            width: 100% !important;
            height: auto !important;
            max-height: 90vh !important;
            transform: none !important;
            margin: 0 !important;
            padding: 24px !important;
            background: transparent !important;
        }

        /* 分享对话框的遮罩 */
        .sharing-dialog ~ .cdk-overlay-backdrop {
            display: block !important;
            opacity: 1 !important;
            visibility: visible !important;
            pointer-events: auto !important;
            background: rgba(0, 0, 0, 0.32) !important;
            position: fixed !important;
            top: 0 !important;
            left: 0 !important;
            right: 0 !important;
            bottom: 0 !important;
            z-index: 9999 !important;
        }

        /* 修复分享对话框内部布局 */
        .sharing-dialog .mat-mdc-dialog-surface {
            display: block !important;
            position: relative !important;
            box-sizing: border-box !important;
        }

        /* 确保分享对话框在正确的位置 */
        .sharing-dialog .cdk-overlay-pane {
            position: fixed !important;
            top: 50% !important;
            left: 50% !important;
            transform: translate(-50%, -50%) !important;
        }
    `);

    debug.log('脚本加载完成');
})();