gf.qytechs.cn - remove lang from url

To remove lang from Greasy Fork镜像's url

目前为 2023-08-03 提交的版本。查看 最新版本

// ==UserScript==
// @name        gf.qytechs.cn - remove lang from url
// @namespace   UserScript
// @match       https://gf.qytechs.cn/*
// @grant       none
// @version     1.0
// @author      CY Fung
// @description To remove lang from Greasy Fork镜像's url
// @run-at      document-start
// @license     MIT
// ==/UserScript==

(function (__CONTEXT__) {



  const { setInterval, clearInterval, Promise } = __CONTEXT__;

  let lastURL = null;

  const langs = [
    "ar",
    "bg",
    "cs",
    "da",
    "de",
    "el",
    "en",
    "eo",
    "es",
    "fi",
    "fr",
    "fr-CA",
    "he",
    "hu",
    "id",
    "it",
    "ja",
    "ka",
    "ko",
    "nb",
    "nl",
    "pl",
    "pt-BR",
    "ro",
    "ru",
    "sk",
    "sr",
    "sv",
    "th",
    "tr",
    "uk",
    "ug",
    "vi",
    "zh-CN",
    "zh-TW"
  ];

  const regex = new RegExp("\/(" + langs.join('|') + ")\/");

  function tim() {

    const url = location.pathname;

    if (url === lastURL) return;
    lastURL = url;


    const m = regex.exec(url);
    if (m) {
      history.replaceState(history.state, '', url.replace(`${m[0]}`, '\/') + location.search);
    }



  }
  let cid = setInterval(tim, 1);



  function onReady() {
    clearInterval(cid);
    cid = 0;
    Promise.resolve().then(tim);
  }

  Promise.resolve().then(() => {
    if (document.readyState !== 'loading') {
      onReady();
    } else {
      window.addEventListener("DOMContentLoaded", onReady, false);
    }
  });



})({ setInterval, clearInterval, Promise });



// No more language tag

QingJ © 2025

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