// ==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