Reddit new.reddit button

Add button to redirect post to new.reddit.com

// ==UserScript==
// @name         Reddit new.reddit button
// @namespace    https://www.reddit.com
// @version      1.0
// @description  Add button to redirect post to new.reddit.com
// @author       Agreasyforkuser
// @match        https://old.reddit.com/*
// @icon         https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png
// @license      MIT
// ==/UserScript==

'use strict';

function changeUrl() {
    // Replace "old" with "new" in the current URL
    var oldUrl = window.location.href;
    var newUrl = oldUrl.replace('old', 'new');

    // Open the new URL in the same window
    window.location.href = newUrl;
}

function createChangeUrlButton() {
    var button = document.createElement('button');
    button.innerHTML = 'new.reddit';
    button.style.color = 'white';
    button.style.background = 'black';
    button.style.border = 'none';
    button.style.fontSize = 'inherit';
    button.onclick = changeUrl;

    // Add the button to the document body
    document.body.appendChild(button);
}

// Call the function to create the "Change URL" button
createChangeUrlButton();