Decode Base64 URL on comohoy.com

Decode Base64 URL parameter and redirect on comohoy.com

// ==UserScript==
// @name         Decode Base64 URL on comohoy.com
// @namespace    https://mrawsky.dev/
// @version      0.1
// @description  Decode Base64 URL parameter and redirect on comohoy.com
// @author       You
// @match        https://comohoy.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function decodeBase64Url(url) {
        return atob(url);
    }

    function getUrlParameter(name) {
        name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
        var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
        var results = regex.exec(location.href);
        return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
    }

    var encodedUrl = getUrlParameter('url');
    if (encodedUrl !== '') {
        var decodedUrl = decodeBase64Url(encodedUrl);
        if (decodedUrl !== '') {
            window.location.href = decodedUrl;
        } else {
            console.error('Error: Unable to decode URL');
        }
    } else {
        console.error('Error: URL parameter not found');
    }
})();