Greasy Fork is available in English.

Clean Cloudflare URL

Remove ugly Cloudflare-generated parameters from the url

  1. // ==UserScript==
  2. // @name Clean Cloudflare URL
  3. // @name:zh-CN 清理 Cloudflare 生成的 URL 参数
  4. // @namespace https://github.com/andylizi
  5. // @version 0.2
  6. // @author andylizi
  7. // @description Remove ugly Cloudflare-generated parameters from the url
  8. // @description:zh-CN 清除 Cloudflare 在 URL 中插入的一长串参数
  9. // @icon https://www.cloudflare.com/favicon.ico
  10. // @include /__cf_chl_(jschl_|captcha_|managed_|rt_|f_|)tk(__)?=/
  11. // @run-at document-start
  12. // @grant none
  13. // @noframes
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. const oldUrl = location.href, url = new URL(oldUrl);
  20. const params = url.searchParams;
  21. ["__cf_chl_jschl_tk__", "__cf_chl_managed_tk__", "__cf_chl_captcha_tk__", "__cf_chl_tk", "__cf_chl_rt_tk", "__cf_chl_f_tk"]
  22. .forEach(p => params.delete(p));
  23. const newUrl = url.toString();
  24. (newUrl !== oldUrl) && history.replaceState(history.state, '', newUrl);
  25. })();