Greasy Fork 支持简体中文。

Cloudflare Plus

Remove or fix ugly Cloudflare generated parameters from the url.

  1. // ==UserScript==
  2. // @name Cloudflare Plus
  3. // @namespace https://greasyfork.org/users/592063
  4. // @version 0.2.2
  5. // @author wuniversales
  6. // @description Remove or fix ugly Cloudflare generated parameters from the url.
  7. // @icon https://icons.duckduckgo.com/ip2/cloudflare.com.ico
  8. // @include /__cf_chl_(jschl|captcha|managed|rt)_tk__=/
  9. // @run-at document-end
  10. // @grant none
  11. // @license MIT
  12. // @noframes
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. async function fix_cloudflare() {
  18. let detected=document.querySelectorAll("div[class^='cf-']").length+document.querySelectorAll("div[id^='cf-']").length;
  19. if(detected==0){
  20. const oldUrl = window.location.href;
  21. const url = new URL(oldUrl);
  22. const params = url.searchParams;
  23. const key=['jschl','captcha','managed','rt'];
  24. for (let i = 0; i < key.length; i++) {
  25. params.delete('__cf_chl_'+key[i]+'_tk__');
  26. }
  27. const newUrl = url.toString();
  28. if(newUrl!==oldUrl){
  29. window.location.replace(newUrl);
  30. }
  31. }
  32. }
  33. window.addEventListener("load", function(){fix_cloudflare();});
  34. })();