Legacy to Latest Curseforge Redirect

Replaces legacy CurseForge links with the current ones, excluding specified patterns

// ==UserScript==
// @name         Legacy to Latest Curseforge Redirect
// @namespace    Violentmonkey Scripts
// @version      0.2
// @description  Replaces legacy CurseForge links with the current ones, excluding specified patterns
// @author       AmeLooksSus
// @match        *://legacy.curseforge.com/minecraft/mc-mods/*
// @exclude      *://legacy.curseforge.com/minecraft/mc-mods/*/relations/dependents*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Get the current URL
    var currentURL = window.location.href;

    // Check if the URL matches the excluded pattern
    if (!currentURL.includes("/relations/dependents")) {
        // Replace legacy URL with the current one
        var newURL = currentURL.replace("legacy.curseforge.com/minecraft/mc-mods/", "curseforge.com/minecraft/mc-mods/");

        // Redirect to the updated URL
        window.location.href = newURL;
    }
})();