Greasy Fork

来自缓存

Greasy Fork is available in English.

体验新版界面

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         体验新版界面
// @namespace    http://tampermonkey.net/
// @version      1.7
// @description  使用洛谷时,打开旧版界面会自动跳转到支持的新版界面
// @author       andyli
// @match        *://*.luogu.org/recordnew/show/*
// @match        *://*.luogu.org/problemnew/show/*
// @match        *://*.luogu.org/problemnew/lists*
// @match        *://*.luogu.org/recordnew/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.*$"),
      reg4 = new RegExp("^https://www.luogu.org/recordnew/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;
  }
  if (reg4.test(str)) {
    var list = window.location.href.match(/pid=.*/);
    if (list === null) {
    } else {
      window.location.href = "https://www.luogu.org/fe/record/list?" + list[0];
    }
  }
  if (reg4.test(str)) {
    var uid = window.location.href.match(/uid=.*/);
    if (uid === null) {
    } else {
      window.location.href =
          "https://www.luogu.org/fe/record/list?user=" + uid[0].substr(4);
    }
  }
})();