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.

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

(I already have a user style manager, let me install it!)

// ==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();

})();