贴吧奇怪域名重定向

把一些奇怪的域名 重定向到tieba.baidu.com(GLM-4编写)

目前为 2024-06-23 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 贴吧奇怪域名重定向
  3. // @version 0.1
  4. // @description 把一些奇怪的域名 重定向到tieba.baidu.com(GLM-4编写)
  5. // @author rteta
  6. // @match https://nba.baidu.com/*
  7. // @match https://c.tieba.baidu.com/*
  8. // @match https://tiebac.baidu.com/*
  9. // @match https://www.tieba.com/*
  10. // @grant none
  11. // @license MIT
  12. // @namespace https://greasyfork.org/users/1217761
  13. // ==/UserScript==
  14. (function() {
  15. 'use strict';
  16.  
  17. // 获取当前页面的URL
  18. var currentURL = window.location.href;
  19.  
  20. // 定义需要重定向的域名
  21. var domainsToRedirect = [
  22. "https://nba.baidu.com",
  23. "https://c.tieba.baidu.com",
  24. "https://tiebac.baidu.com",
  25. "https://www.tieba.com"
  26. ];
  27.  
  28. // 目标URL
  29. var targetURL = "https://tieba.baidu.com";
  30.  
  31. // 检查当前URL是否包含需要重定向的域名
  32. for (var i = 0; i < domainsToRedirect.length; i++) {
  33. if (currentURL.startsWith(domainsToRedirect[i])) {
  34. // 将页面重定向到目标URL
  35. window.location.href = currentURL.replace(domainsToRedirect[i], targetURL);
  36. break;
  37. }
  38. }
  39. })();