Remove Redundant URL Search Parameters

Remove Redundant URL Search Parameters like fbclid

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         Remove Redundant URL Search Parameters
// @namespace    https://github.com/livinginpurple
// @version      2019.08.03.14
// @description  Remove Redundant URL Search Parameters like fbclid
// @author       livinginpurple
// @license      WTFPL
// @exclude      https://*.google.com/*
// @exclude      https://*.facebook.com/*
// @exclude      https://www.plurk.com/*
// @include 	 *
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    console.log(GM_info.script.name + " is loading.");;
    let TotalReplaceUri = location.href.split("?")[0];
    let FirstSearchParameter = location.search.split('&')[0];
    let PartialReplaceUri = TotalReplaceUri + FirstSearchParameter;
    let keywords = ["fbclid", "jobsource", "from=fb", "f=cs", "gclid", "utm_", "from=udn"];

    keywords.forEach(element => {
        if (location.href.includes(element)) {
            ModifyUrl(TotalReplaceUri);
        }
    });

    if (PartialReplaceUri.includes("fbclid") && !FirstSearchParameter.includes("fbclid")) {
        ModifyUrl(PartialReplaceUri);
    }

    function ModifyUrl(replaceUri) {
        // 修改網址,且不留下歷史紀錄
        window.history.replaceState({},
            window.title,
            replaceUri
        );
    }
    console.log(GM_info.script.name + " is running.");
})(document);