体验新版界面

使用洛谷时,打开旧版界面会自动跳转到支持的新版界面

目前为 2019-06-23 提交的版本。查看 最新版本

// ==UserScript==
// @name         体验新版界面
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  使用洛谷时,打开旧版界面会自动跳转到支持的新版界面
// @author       andyli
// @match        *://*.luogu.org/recordnew/show/*
// @match        *://*.luogu.org/problemnew/show/*
// @match        *://*.luogu.org/problemnew/lists*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';
  var reg1 = new RegExp("^https://www.luogu.org/recordnew/show/.*$"),
      reg2 = new RegExp("^https://www.luogu.org/problemnew/show/.*$"),
      reg3 = new RegExp("^https://www.luogu.org/problemnew/lists.*$");
  var str = window.location.href;
  if (reg3.test(str)) {
    var name;
    if (str == "https://www.luogu.org/problemnew/lists") {
      window.location.href = "https://www.luogu.org/fe/problem/list";
    } else {
      name = window.location.href.match(/ name =.*/)[0].substr(5);
      window.location.href =
          "https://www.luogu.org/fe/problem/list?keyword=" + name;
    }
  }
  if (reg1.test(str)) {
    var record = window.location.href.match(/ show\/ [0 - 9] + /)[0].substr(5);
    console.log(record);
    window.location.href = "https://www.luogu.org/fe/record/" + record;
  }
  if (reg2.test(str)) {
    var problem = window.location.href.match(/ show.*/)[0].substr(5);
    console.log(problem);
    window.location.href = "https://www.luogu.org/fe/problem/" + problem;
  }
})();

QingJ © 2025

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