Cloudflare ugly token remove from url

Removes the tokenized cloudflare query from url

  1. // ==UserScript==
  2. // @name Cloudflare ugly token remove from url
  3. // @namespace http://tampermonkey.net/
  4. // @version 1
  5. // @description Removes the tokenized cloudflare query from url
  6. // @author Root Android And Ethical Hacker
  7. // @match *://*/*
  8. // @grant none
  9. // @exclude /^https?://.*amazon\.*/*
  10. // @exclude /^https?://.*google\.*/*
  11. // @exclude /^https?://.*youtube\.*/*
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. function detectQueryString(url) {
  18. var pattern = new RegExp(/[\?&](__cf_chl_jschl_tk__|__cf_chl_captcha_tk__)=[^&]+/);
  19.  
  20. return pattern.test(url);
  21. }
  22.  
  23. function start(){
  24. var detect = detectQueryString(window.location.href);
  25. if(detect){
  26. console.log('%c Ugly Cloudflare url removed','color: red; font-size: 20px');
  27. history.replaceState && history.replaceState(
  28. null, '', location.pathname + location.search.replace(/[\?&](__cf_chl_jschl_tk__|__cf_chl_captcha_tk__)=[^&]+/, '').replace(/^&/, '?') + location.hash
  29. );
  30. }else{
  31. console.log('Ugly Cloudflare url not found!!');
  32. }
  33. }
  34. start();
  35. })();