Clean Cloudflare URL

Remove ugly Cloudflare-generated parameters from the url

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name               Clean Cloudflare URL
// @name:zh-CN         清理 Cloudflare 生成的 URL 参数
// @namespace          https://github.com/andylizi
// @version            0.2
// @author             andylizi
// @description        Remove ugly Cloudflare-generated parameters from the url
// @description:zh-CN  清除 Cloudflare 在 URL 中插入的一长串参数
// @icon               https://www.cloudflare.com/favicon.ico
// @include            /__cf_chl_(jschl_|captcha_|managed_|rt_|f_|)tk(__)?=/
// @run-at             document-start
// @grant              none
// @noframes
// ==/UserScript==

(function() {
    'use strict';

    const oldUrl = location.href, url = new URL(oldUrl);
    const params = url.searchParams;
    ["__cf_chl_jschl_tk__", "__cf_chl_managed_tk__", "__cf_chl_captcha_tk__", "__cf_chl_tk", "__cf_chl_rt_tk", "__cf_chl_f_tk"]
        .forEach(p => params.delete(p));
    const newUrl = url.toString();
    (newUrl !== oldUrl) && history.replaceState(history.state, '', newUrl);
})();