Facebook Remove Redundant URL Ref

Remove refsrc and tracking parameters from Facebook URLs

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Facebook Remove Redundant URL Ref
// @namespace    https://github.com/livinginpurple
// @version      2025.11.28.09
// @description  Remove refsrc and tracking parameters from Facebook URLs
// @license      WTFPL
// @author       livinginpurple
// @match        https://*.facebook.com/*
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    //https://m.facebook.com/story.php?story_fbid=426978937875840&id=291618078078594&refid=7&__tn__=-R

    const TARGET_PARAMS = ['refsrc', 'refid', '_rdr' , '__tn__', '__xts__', 'hrc', 'fbclid', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'gclid', 'igshid', 'mc_cid', 'mc_eid', 'mkt_tok', 'dclid', 'fb_ref', 'fb_source', 'fref', 'efid', 'hsa_acc', 'hsa_cam', 'hsa_grp', 'hsa_ad', 'hsa_src', 'hsa_tgt', 'hsa_kw', 'hsa_mt', 'hsa_net'];
    try {
        const currentUrl = new URL(window.location.href);
        const searchParams = currentUrl.searchParams;
        let hasModified = false;

        TARGET_PARAMS.forEach(param => {
            if (searchParams.has(param)) {
                searchParams.delete(param);
                hasModified = true;
            }
        });

        if (hasModified) {
            const newUrl = currentUrl.toString();
            window.history.replaceState(null, '', newUrl);
            console.log(`${GMInfo.script.name} URL clean: ${newUrl}`);
        }

    } catch (e) {
        console.error(`${GMInfo.script.name} Error processing URL:`, e);
    }
})();