自动跳转到中文网站

当打开其他语言的官方网站时,自动重定向到相应的中文官方网站。支持: Rollup Vue.js Vite webpack Pinia VueRouter

  1. // ==UserScript==
  2. // @name AutoRedirectCN
  3. // @name:zh-CN 自动跳转到中文网站
  4. // @namespace http://www.wasdjkl.com/
  5. // @version 0.3
  6. // @description Automatically redirect to the corresponding Chinese official website when opening official websites in other languages. Support: Rollup Vue.js Vite webpack Pinia VueRouter
  7. // @description:zh-CN 当打开其他语言的官方网站时,自动重定向到相应的中文官方网站。支持: Rollup Vue.js Vite webpack Pinia VueRouter
  8. // @run-at document-start
  9. // @author wasdjkl
  10. // @match https://*.rollupjs.org/*
  11. // @match https://*.vuejs.org/*
  12. // @match https://*.vitejs.dev/*
  13. // @match https://webpack.kr/*
  14. // @match https://webpack.js.org/*
  15. // @match https://pinia.vuejs.org/*
  16. // @match https://router.vuejs.org/*
  17. // @copyright https://www.wasdjkl.com
  18. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  19. // @grant none
  20. // @license MIT
  21. // ==/UserScript==
  22.  
  23. (function () {
  24. 'use strict'
  25. const url = location.href.toString()
  26. const redirectRules = [
  27. // Rollup
  28. { regex: /^https:\/\/rollupjs.org\//, cn: 'https://cn.rollupjs.org/' },
  29. // Vue.js
  30. { regex: /^https:\/\/(ja|ua|fr)?.?vuejs.org\//, cn: 'https://cn.vuejs.org/' },
  31. // Vite
  32. { regex: /^https:\/\/(ja|es|pt)?.?vitejs.dev\//, cn: 'https://cn.vitejs.dev/' },
  33. // webpack
  34. { regex: /^https:\/\/webpack.(kr|js.org)+\//, cn: 'https://webpack.docschina.org/' },
  35. // Pinia
  36. { regex: /^https:\/\/pinia.vuejs.org\//, cn: 'https://pinia.vuejs.org/zh/' },
  37. // VueRouter
  38. { regex: /^https:\/\/router.vuejs.org\//, cn: 'https://router.vuejs.org/zh/' },
  39. ]
  40.  
  41. for (const rules of redirectRules) {
  42. const { regex, cn } = rules
  43. if (regex.test(url)) {
  44. if (url.startsWith(cn))
  45. return
  46. location.href = url.replace(regex, cn)
  47. }
  48. }
  49. })()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址