Greasy Fork 支持简体中文。

贴吧奇怪域名重定向

把一些奇怪的域名重定向到tieba.baidu.com

目前為 2024-07-17 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name 贴吧奇怪域名重定向
  3. // @version 0.4.1
  4. // @description 把一些奇怪的域名重定向到tieba.baidu.com
  5. // @author rteta
  6. // @match *://nba.baidu.com/*
  7. // @match *://c.tieba.baidu.com/*
  8. // @match *://tiebac.baidu.com/*
  9. // @match *://www.tieba.com/*
  10. // @match *://fexclick.baidu.com/*
  11. // @match *://youhua.baidu.com/*
  12. // @match *://ala.baidu.com/*
  13. // @match *://static.tieba.baidu.com/*
  14. // @grant none
  15. // @license MIT
  16. // @namespace https://greasyfork.org/users/1217761
  17. // ==/UserScript==
  18. //(0.4.1以前GLM4编写,以后是GPT4o优化)
  19. (function() {
  20. 'use strict';
  21.  
  22. // 获取当前页面的URL
  23. var currentURL = window.location.href;
  24.  
  25. // 定义需要重定向的域名(使用正则表达式以支持http和https)
  26. var domainsToRedirect = [
  27. /^https?:\/\/nba\.baidu\.com/,
  28. /^https?:\/\/c\.tieba\.baidu\.com/,
  29. /^https?:\/\/tiebac\.baidu\.com/,
  30. /^https?:\/\/www\.tieba\.com/,
  31. /^https?:\/\/youhua\.baidu\.com/,
  32. /^https?:\/\/ala\.baidu\.com/,
  33. /^https?:\/\/static\.tieba\.baidu\.com/,
  34. /^https?:\/\/fexclick\.baidu\.com/
  35. ];
  36.  
  37. // 目标URL
  38. var targetURL = "https://tieba.baidu.com";
  39.  
  40. // 检查当前URL是否匹配需要重定向的域名
  41. for (var i = 0; i < domainsToRedirect.length; i++) {
  42. if (domainsToRedirect[i].test(currentURL)) {
  43. // 将页面重定向到目标URL
  44. window.location.href = currentURL.replace(domainsToRedirect[i], targetURL);
  45. break;
  46. }
  47. }
  48. })();