Steam button for Keymailer

Add a link to Steam search for games on Keymailer.co

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 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          Steam button for Keymailer
// @name:ru       Кнопка Steam для Keymailer
// @namespace     https://www.keymailer.co/g/games
// @version       2.0
// @description   Add a link to Steam search for games on Keymailer.co
// @description:ru Добавляет ссылку на поиск игр в Steam на Keymailer.co
// @author        Fan4eG
// @match         https://www.keymailer.co/g/games/*
// @grant         none
// ==/UserScript==

(function() {
    'use strict';

    function removeSpecialCharacters(string) {
        return string.replace(/™/g, '').replace(/®/g, '').replace(/©/g, '').replace(/℠/g, '').replace(/℗/g, '').replace(/™️/g, '').replace(/©️/g, '');
    }

    function addSteamLinkButton() {
        const pathArray = window.location.pathname.split('/');
        const gameId = pathArray[pathArray.length - 1];

        const gameTitleElement = document.querySelector('h1');
        const gameTitle = removeSpecialCharacters(gameTitleElement.textContent.trim());

        const button = document.createElement('button');
        button.innerHTML = 'STEAM';
        button.style.position = 'absolute';
        button.style.top = '0';
        button.style.right = '0';
        button.style.padding = '5px';
        button.style.background = 'rgb(17, 99, 231)';
        button.style.color = 'white';
        button.style.zIndex = '9999';
        button.style.cursor = 'pointer';
        button.style.fontFamily = 'inherit';
        button.style.border = '2px solid black';

        button.addEventListener('click', function() {
            window.open('https://store.steampowered.com/search/?term=' + encodeURI(gameTitle), '_blank');
        });

        gameTitleElement.style.position = 'relative';
        gameTitleElement.appendChild(button);
    }

    addSteamLinkButton();
})();