避免洛谷提示Request Blocked

在使用洛谷时,如果回退页面或前进页面经常会遇到`Request Blocked`的情况,这个脚本能检测并自动刷新页面。

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         避免洛谷提示Request Blocked
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  在使用洛谷时,如果回退页面或前进页面经常会遇到`Request Blocked`的情况,这个脚本能检测并自动刷新页面。
// @author       gandyli
// @match        *://*.luogu.org/*
// @exclude      *://*.luogu.org/login/logout?uid=*
// @exclude      *://*.luogu.org/ide
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var reg1 = new RegExp("^((?!blog).)*https://www.luogu.org((?!blog).)*$"), reg2 = new RegExp("^((?!blog).)*http://www.luogu.org((?!blog).)*$"), reg3= new RegExp("^((?!blog).)*https://www2.luogu.org((?!blog).)*$"), reg4=new RegExp("^((?!blog).)*http://www2.luogu.org((?!blog).)*$");
    var str = window.location.href;
    if (reg1.test(str) || reg2.test(str) || reg3.test(str) || reg4.test(str)){
     if (document.getElementById("app-header")===null)
     {
            location.reload();
     }}
})();