Greasy Fork

Greasy Fork is available in English.

洛谷用户查找

在洛谷主页添加类似Codeforces的Find User(暂不支持自动补全)

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         洛谷用户查找
// @version      0.1.9
// @description  在洛谷主页添加类似Codeforces的Find User(暂不支持自动补全)
// @author       叶ID (KMnO4y_Fish, yezhiyi9670)
// @match        *://www.luogu.com.cn/
// @match        *://www.luogu.com.cn/
// @namespace    http://greasyfork.icu/zh-CN/users/370663-yezhiyi9670
// ==/UserScript==

(function () {
  $('document').ready(function(){setTimeout(function () {
    $sidebar = $('#app-old .lg-index-content .lg-right.am-u-lg-3');
    $firstele = $($sidebar.children()[0]);
    // console.log($firstele);
    $finder = $(`
      <div class="lg-article" id="find-user-form">
        <h2>查找用户</h2>
        <form id="find-user-form">
          <input type="text" class="am-form-field" name="finder-uid" placeholder="用户名或uid" autocomplete="off" />
        </form>
        <button class="am-btn am-btn-sm am-btn-primary" style="margin-top:16px;visibility:hidden">查找</button>
        <button class="am-btn am-btn-sm am-btn-primary lg-right" id="find-user-button" style="margin-top:16px;">查找</button>
      </div>
    `);
    $finder.insertAfter($firstele);
    var find_func = function() {
      $('#find-user-button').addClass('am-disabled');
      $.get("/fe/api/user/search?keyword=" + $('[name=finder-uid]')[0].value,
        function (data) {
          var arr = data;
          if (!arr['users'][0]) {
            $('#find-user-button').removeClass('am-disabled');
            show_alert("好像哪里有点问题", "无法找到指定用户");
          }
          else {
            location.href = "/user/"+arr['users'][0]['uid'];
          }
        }
      );
      return false;
    };
    $('#find-user-button').click(find_func);
    $('#find-user-form').submit(find_func);
    
  },500)});
})();