Google Gemini - Direct Links

Removes the google.com/search?q= redirection wrapper from links generated by Google Gemini, allowing you to open external websites directly.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Google Gemini - Direct Links
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Removes the google.com/search?q= redirection wrapper from links generated by Google Gemini, allowing you to open external websites directly.
// @author       YourUsername
// @license      MIT
// @match        https://gemini.google.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gemini.google.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to clean the redirect links
    function cleanRedirectLinks() {
        // Select all links starting with the Google Search redirect prefix
        const links = document.querySelectorAll('a[href^="https://www.google.com/search?q="]');

        links.forEach(link => {
            // Prevent processing the same link multiple times
            if (link.dataset.cleaned === "true") return;

            try {
                // Parse the current URL
                const urlObj = new URL(link.href);
                // Extract the 'q' parameter which contains the real URL
                const realUrl = urlObj.searchParams.get('q');

                // Check if realUrl exists and starts with http/https (to avoid breaking legitimate text searches)
                if (realUrl && (realUrl.startsWith('http://') || realUrl.startsWith('https://'))) {

                    // Replace the redirect link with the direct URL
                    link.href = realUrl;

                    // Optional: Force open in new tab to keep Gemini chat active
                    link.target = "_blank";
                    link.rel = "noopener noreferrer";

                    // Mark as cleaned to avoid re-processing
                    link.dataset.cleaned = "true";
                }
            } catch (e) {
                console.error("Gemini Direct Links - Error cleaning link:", e);
            }
        });
    }

    // Create a MutationObserver to handle dynamic content loading (SPA)
    const observer = new MutationObserver((mutations) => {
        cleanRedirectLinks();
    });

    // Start observing the body for changes
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    // Initial run
    cleanRedirectLinks();

})();