Greasy Fork is available in English.
You can use /user/ztrztr to find the user called "ztrztr"!
当前为
// ==UserScript==
// @name Find User
// @namespace http://tampermonkey.net/
// @version 0.2
// @description You can use /user/ztrztr to find the user called "ztrztr"!
// @author ztrztr
// @match *://*.www.luogu.com.cn/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=luogu.com.cn
// @grant none
// ==/UserScript==
(function() {
'use strict';
//check update
var code_updated_at = "114514";
fetch('http://greasyfork.icu/zh-CN/scripts/471200.json')
.then(response => response.json())
.then(data => {
if (localStorage.getItem("code_updated_at") != data.code_updated_at) alert("UPDATE!http://greasyfork.icu/zh-CN/scripts/471200-find-user")
});
var url = window.location.href;
var res = url.split("/");
if (res[3] == "user") {
fetch('https://www.luogu.com.cn/api/user/search?keyword=' + res[4])
.then(response => response.json())
.then(data => {
console.log(data.users[0]);
var dataa = data.users[0]
console.log(dataa.uid);
if (data.users.length == 0) window.location.replace("https://www.luogu.com.cn/");
if (res[4] != dataa.uid.split("#")[0]) {
window.location.replace("https://www.luogu.com.cn/user/" + dataa.uid);
}
});
}
// Your code here...
})();