Flyert Universal Dynamic URL Redirector

Redirect from specific URL to another while maintaining parameters, excluding mobile=yes

  1. // ==UserScript==
  2. // @name Flyert Universal Dynamic URL Redirector
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description Redirect from specific URL to another while maintaining parameters, excluding mobile=yes
  6. // @author You
  7. // @match https://47.100.65.202/forum.php*
  8. // @match https://www.flyert.com.cn/forum.php*
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const currentUrl = window.location.href;
  17.  
  18. // Check if the URL contains the IP address
  19. if (/47\.100\.65\.202/.test(currentUrl)) {
  20. // Replace IP address with the domain
  21. const newUrl = currentUrl.replace(/47\.100\.65\.202/, 'www.flyert.com');
  22. // Redirect to the new URL
  23. window.location.href = newUrl;
  24. } else {
  25. // Just remove '&mobile=yes' if the URL is not the IP address
  26. const newUrl = currentUrl.replace(/&mobile=yes/, '');
  27. if (newUrl !== currentUrl) {
  28. window.location.href = newUrl;
  29. }
  30. }
  31. })();