AI Conversation Navigator

Floating navigator for your prompts in ChatGPT, Gemini, Aistudio, NotebookLM, Grok, Claude, Mistral, Perplexity, Meta, Poe, Huggingface, Deepseek, Kimi, Qwen, Z.ai, Longcat, Chatglm, Chatboxai, Lmarena, Paperfigureqa (allen), Scira, Scispace, Exa.ai, Consensus, Openevidence, Pathway, Math-gpt conversations.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         AI Conversation Navigator
// @namespace    https://greasyfork.org
// @version      5.3
// @description  Floating navigator for your prompts in ChatGPT, Gemini, Aistudio, NotebookLM, Grok, Claude, Mistral, Perplexity, Meta, Poe, Huggingface, Deepseek, Kimi, Qwen, Z.ai, Longcat, Chatglm, Chatboxai, Lmarena, Paperfigureqa (allen), Scira, Scispace, Exa.ai, Consensus, Openevidence, Pathway, Math-gpt conversations.
// @author       Bui Quoc Dung
// @match        https://chatgpt.com/*
// @match        https://gemini.google.com/*
// @match        https://aistudio.google.com/*
// @match        https://notebooklm.google.com/*
// @match        https://grok.com/*
// @match        https://claude.ai/*
// @match        https://www.kimi.com/*
// @match        https://chat.mistral.ai/*
// @match        https://www.perplexity.ai/*
// @match        https://www.meta.ai/*
// @match        https://poe.com/*
// @match        https://huggingface.co/chat/*
// @match        https://chat.deepseek.com/*
// @match        https://chat.qwen.ai/*
// @match        https://chat.z.ai/*
// @match        https://longcat.chat/*
// @match        https://chatglm.cn/*
// @match        https://web.chatboxai.app/*
// @match        https://lmarena.ai/*
// @match        https://paperfigureqa.allen.ai/*
// @match        https://scira.ai/*
// @match        https://scispace.com/*
// @match        https://exa.ai/*
// @match        https://consensus.app/*
// @match        https://www.openevidence.com/*
// @match        https://www.pathway.md/*
// @match        https://math-gpt.org/*
// @grant        GM_addStyle
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const NAV_WIDTH = 250;
    const NAV_COLLAPSED_WIDTH = 80;
    let activeMessageIndex = -1;

    const BASE_CONTAINER_CSS = `
        right: 0px; width: ${NAV_WIDTH}px; max-height: 90vh; overflow-y: auto;
        z-index: 9999;
        transition: width 0.3s, padding 0.3s, opacity 0.3s, transform 0.3s;
        font-family: Calibri, sans-serif; font-size: 17px; color: CanvasText; position: fixed;text-align: left;
    `;

    const getShiftStyle = (width, selector = '') => {
        const selectors = selector.split(',');
        const prefixedSelector = selectors.map(s => `body.navigator-expanded ${s.trim()}`).join(', ');
        return `
            ${selector} {
                transition: margin-right 0.3s ease, max-width 0.3s ease, margin-left 0.3s ease;
            }
            ${prefixedSelector} {
                margin-left: 0 !important;
                margin-right: ${width}px !important;
                max-width: calc(100% - ${width}px) !important;
            }
        `;
    };

    GM_addStyle(`
        .nav-list-item {
            font-weight: normal;
            transition: font-weight 0.1s ease;
        }
        .nav-list-item.active {
            font-weight: bold !important;
            background-color: rgba(0, 0, 0, 0.05);
        }
    `);


    function getAIStudioData() {
        const prompts = [];
        const scrollButtons = document.querySelectorAll('ms-prompt-scrollbar button[id^="scrollbar-item-"]');
        scrollButtons.forEach(btn => {
            const isUser = btn.querySelector('.prompt-scrollbar-dot');
            if (isUser) {
                const text = btn.getAttribute('aria-label');
                if (text) {
                    prompts.push({
                        element: btn,
                        text: text.trim()
                    });
                }
            }
        });
        return prompts;
    }

    const SITE_CONFIG = {
        chatgpt: {
            match: /chatgpt\.com/,
            msgSelector: 'div[data-message-author-role="user"]',
            top: '55px',
            shiftTarget: 'main, .draggable'
        },
        gemini: {
            match: /gemini\.google\.com/,
            msgSelector: '.query-text',
            top: '55px',
            shiftTarget: 'chat-app,.boqOnegoogleliteOgbOneGoogleBar, top-bar-actions'
        },
        aistudio: {
            match: /aistudio\.google\.com/,
            customFinder: getAIStudioData,
            top: '55px',
            useClick: true
        },
        notebooklm: {
            match: /notebooklm\.google\.com/,
            msgSelector: 'chat-message .from-user-container',
            top: '55px',
            shiftTarget: 'notebook, .boqOnegoogleliteOgbOneGoogleBar'
        },
        grok: {
            match: /grok\.com/,
            msgSelector: '.relative.group.flex.flex-col.justify-center.items-end',
            top: '55px'
        },
        claude: {
            match: /claude\.ai/,
            msgSelector: 'div.group.relative.inline-flex',
            top: '55px',
        },
        mistral: {
            match: /chat\.mistral\.ai/,
            msgSelector: 'div[data-message-author-role="user"]',
            top: '55px',
            shiftTarget: 'main.bg-sidebar-subtle'
        },
        perplexity: {
            match: /perplexity\.ai/,
            msgSelector: 'div.group\\/title',
            top: '55px'
        },
        meta: {
            match: /meta\.ai/,
            msgSelector: '.x78zum5.x15zctf7',
            top: '55px'
        },
        poe: {
            match: /poe\.com/,
            msgSelector: '[class*="ChatMessagesView_tupleGroupContainer"] > div > div:first-child',
            top: '55px',
            shiftTarget: '[class*="CanvasSidebarLayout_chat-column"]'
        },
        huggingface: {
            match: /huggingface\.co/,
            msgSelector: '.disabled.w-full.appearance-none',
            top: '55px',
            shiftTarget: '.relative.min-h-0.min-w-0'

        },
        deepseek: {
            match: /chat\.deepseek\.com/,
            msgSelector: '#root > div > div > div:nth-child(2) > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(2) > div:nth-child(1) > div:nth-child(odd)',
            top: '55px',
            shiftTarget: '#root > div > div > div:nth-child(2) > div:nth-child(3) > div > div:nth-child(2) > div'
        },
        kimi: {
            match: /www\.kimi\.com/,
            msgSelector: '.user-content',
            top: '55px'
        },
        glm: {
            match: /chat\.z\.ai/,
            msgSelector: '.chat-user',
            top: '55px'
        },
        qwen: {
            match: /chat\.qwen\.ai/,
            msgSelector: '.chat-user-message',
            top: '55px'
        },
        longcat: {
            match: /longcat\.chat/,
            msgSelector: '.user-message .user-message',
            top: '55px',
            shiftTarget: '.page-container'
        },
        chatglm: {
            match: /chatglm\.cn/,
            msgSelector: '.question-txt.dots',
            top: '55px',
        },
        chatboxai: {
            match: /web\.chatboxai\.app/,
            msgSelector: '.user-msg',
            top: '55px',
        },
        lmarena: {
            match: /lmarena\.ai/,
            msgSelector: '.justify-end.gap-2',
            top: '55px',
        },
        paperfigure: {
            match: /paperfigureqa\.allen\.ai/,
            msgSelector: '#chat-scroll-container > div > div:nth-of-type(odd) .MuiPaper-root',
            top: '55px'
        },
        scira: {
            match: /scira\.ai/,
            msgSelector: '.max-w-full .relative',
            top: '55px',
            shiftTarget: '.sm\\:max-w-2xl'
        },
        scispace: {
            match: /scispace\.com/,
            msgSelector: '.max-w-lg',
            top: '55px',
        },
        exa: {
            match: /exa\.ai/,
            msgSelector: 'div[data-test-id="UserMessage"]',
            top: '55px',
            shiftTarget: 'div[data-test-id="ChatPresentation"]'
        },
        consensus: {
            match: /consensus\.app/,
            msgSelector: '.flex.flex-col.pt-6.w-full.max-w-page h2',
            top: '55px',
        },
        openevidence: {
            match: /openevidence\.com/,
            msgSelector: '.brandable--query-bar--container form',
            top: '55px',
            shiftTarget: '#__next, .brandable--query-bar--container.hide-on-print.follow-up'
        },
        pathway: {
            match: /pathway\.md/,
            msgSelector: '[id] > div > div > div .chakra-text',
            top: '55px',
        },
        mathgpt: {
            match: /math-gpt\.org/,
            msgSelector: '.w-full.flex.items-end.flex-col.pb-8.relative',
            top: '55px',
            shiftTarget: '.overflow-x-hidden, .px-2.flex.flex-col.gap-1'
        },
    };

    const site = Object.values(SITE_CONFIG).find(s => s.match.test(location.hostname));
    if (!site) return;

    const currentWidth = site.width || NAV_WIDTH;
    GM_addStyle(getShiftStyle(currentWidth, site.shiftTarget || ''));

    let conversationObserver = null;
    let isCollapsed = false;
    window.navigatorUpdateTimeout = null;

    function updateBodyClassForLayout() {
        const container = document.getElementById('message-nav');
        const content = document.getElementById('message-nav-content');
        if (container && content && content.style.display !== 'none') {
            document.body.classList.add('navigator-expanded');
        } else {
            document.body.classList.remove('navigator-expanded');
        }
    }

    function createContainer() {
        let container = document.getElementById('message-nav');
        if (!container) {
            container = document.createElement('div');
            container.id = 'message-nav';
            container.className = site.bgClass || '';
            container.style.cssText = `top: ${site.top}; ${BASE_CONTAINER_CSS}`;

            const header = document.createElement('div');
            Object.assign(header.style, {
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                cursor: 'pointer',
                fontWeight: 'bold'
            });

            const toggleBtn = document.createElement('button');
            Object.assign(toggleBtn.style, {
                background: 'none',
                border: 'none',
                cursor: 'pointer',
                fontSize: '18px',
                color: 'inherit'
            });
            toggleBtn.textContent = 'Close';
            header.appendChild(toggleBtn);

            const content = document.createElement('div');
            content.id = 'message-nav-content';
            content.style.padding = '5px';

            container.appendChild(header);
            container.appendChild(content);
            document.body.appendChild(container);

            const toggleHandler = (e) => {
                e.stopPropagation();
                isCollapsed = !isCollapsed;
                if (!isCollapsed) {
                    content.style.display = 'block';
                    container.style.width = `${currentWidth}px`;
                    toggleBtn.textContent = 'Close';
                } else {
                    content.style.display = 'none';
                    container.style.width = `${NAV_COLLAPSED_WIDTH}px`;
                    toggleBtn.textContent = 'Open';
                }
                updateBodyClassForLayout();
            };

            toggleBtn.addEventListener('click', toggleHandler);
            updateBodyClassForLayout();
        }
        return container;
    }

    function findUserPrompts() {
        if (site.customFinder) {
            return site.customFinder();
        }
        const prompts = [];
        if (!site.msgSelector) return prompts;

        const elements = document.querySelectorAll(site.msgSelector);
        elements.forEach((element) => {
            const text = element.textContent.trim();
            if (text) prompts.push({ element, text });
        });

        return prompts;
    }

    function createListItem(prompt, index) {
        const listItem = document.createElement('li');
        const preview = prompt.text.length > 80 ? prompt.text.slice(0, 80) + '...' : prompt.text;
        listItem.textContent = `${index}. ${preview}`;
        Object.assign(listItem.style, {
            cursor: 'pointer',
            padding: '5px 0px 5px 5px'
        });
        listItem.classList.add('nav-list-item');
        if (index === activeMessageIndex) {
            listItem.classList.add('active');
        }

        listItem.addEventListener('click', () => {
            listItem.parentElement.querySelectorAll('.nav-list-item').forEach(li => li.classList.remove('active'));
            listItem.classList.add('active');
            activeMessageIndex = index;


            if (site.useClick) {
                prompt.element.click();
            } else {
                prompt.element.scrollIntoView({ behavior: 'smooth', block: 'start' });
            }
        });

        return listItem;
    }

    function updateMessageList() {
        const container = createContainer();
        const content = document.getElementById('message-nav-content');
        if (!content) return;

        let list = content.querySelector('ul');
        if (!list) {
            list = document.createElement('ul');
            list.style.cssText = 'padding: 0; margin: 0; list-style: none;';
            content.appendChild(list);
        }

        const prompts = findUserPrompts();

        while (list.firstChild) {
            list.removeChild(list.firstChild);
        }

        if (prompts.length === 0) {
            activeMessageIndex = -1;
            const noContent = document.createElement('div');
            noContent.textContent = 'Loading...';
            noContent.style.cssText = 'color: #999; font-style: italic; text-align: center; padding: 15px 0;';
            list.appendChild(noContent);
            return;
        }

        prompts.forEach((prompt, index) => {
            const listItem = createListItem(prompt, index + 1);
            list.appendChild(listItem);
        });
    }

    function observeConversation() {
        if (conversationObserver) conversationObserver.disconnect();

        conversationObserver = new MutationObserver(() => {
            clearTimeout(window.navigatorUpdateTimeout);
            window.navigatorUpdateTimeout = setTimeout(() => {
                updateMessageList();
            }, 501);
        });

        conversationObserver.observe(document.body, {
            childList: true,
            subtree: true
        });
    }

    setTimeout(() => updateMessageList(), 1000);
    observeConversation();

})();