Universal Tracker Remover

Removes common tracking parameters (e.g., utm_source, fbclid, from) from all links and the browser address bar, on all websites.

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.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

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         Universal Tracker Remover
// @namespace    https://cleanlinks.net/
// @version      1.0
// @description  Removes common tracking parameters (e.g., utm_source, fbclid, from) from all links and the browser address bar, on all websites.
// @author       DiCK
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // List of tracking parameters to remove
    const trackingParams = [
        'utm_source',
        'utm_medium',
        'utm_campaign',
        'utm_term',
        'utm_content',
        'fbclid',
        'gclid',
        'mc_cid',
        'mc_eid',
        'ref',
        'ref_',
        'from'
    ];

    // Remove trackers from a given URL string
    function removeTrackersFromUrl(urlString) {
        try {
            const url = new URL(urlString, window.location.origin);
            let modified = false;

            trackingParams.forEach(param => {
                if (url.searchParams.has(param)) {
                    url.searchParams.delete(param);
                    modified = true;
                }
            });

            return modified ? url.toString() : urlString;
        } catch (e) {
            // Fail silently if invalid URL
            return urlString;
        }
    }

    // Clean all anchor tags on the page
    function cleanLinks() {
        const links = document.querySelectorAll('a[href*="?"], a[href*="&"]');

        links.forEach(link => {
            const cleaned = removeTrackersFromUrl(link.href);
            if (cleaned !== link.href) {
                link.href = cleaned;
            }
        });
    }

    // Clean the browser address bar (without reloading the page)
    function cleanAddressBar() {
        const currentUrl = window.location.href;
        const cleaned = removeTrackersFromUrl(currentUrl);

        if (cleaned !== currentUrl) {
            const urlObj = new URL(cleaned);
            const newUrl = urlObj.pathname + urlObj.search + urlObj.hash;
            window.history.replaceState(null, '', newUrl);
        }
    }

    // Run immediately
    cleanLinks();
    cleanAddressBar();

    // Watch for dynamic changes (e.g., AJAX navigation)
    const observer = new MutationObserver(() => {
        cleanLinks();
    });

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