rurre / Gfycat Details Page Redirect

// ==UserScript==
// @name        Gfycat Details Page Redirect
// @namespace   rurre
// @description Redirects to the old direct gfycat page
// @include     *gfycat.com/gifs/detail/*
// @include     *gfycat.com/*/gifs/detail*
// @version     1
// @grant       none
// ==/UserScript==

const matches = /^\/(?:[a-z]{2}\/)?gifs\/detail\/([^/]+)/i.exec(location.pathname);

if (matches !== null) 
{
    history.replaceState(null, null, '/' + matches[1]);
    location.reload();
}